(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._wrapper_1xs2z_1{--gc-paper: #f2f0ea;box-sizing:border-box;width:100%;height:100%;min-height:100%;margin:0;padding:0;border:1px solid color-mix(in srgb,var(--gc-border, #34516f) 72%,transparent);border-radius:24px;background:radial-gradient(circle at 12% 8%,color-mix(in srgb,var(--gc-primary, #45c4b0) 16%,transparent),transparent 34%),radial-gradient(circle at 88% 10%,color-mix(in srgb,var(--gc-accent, #ff7a59) 14%,transparent),transparent 28%),linear-gradient(160deg,var(--gc-bg, #0d1117),var(--gc-bg-secondary, #182237));color:var(--gc-text, #f1f4ef);box-shadow:0 24px 64px #00000047;display:grid;place-items:center}._wrapper_1xs2z_1,._wrapper_1xs2z_1 *,._wrapper_1xs2z_1 *:before,._wrapper_1xs2z_1 *:after{box-sizing:inherit}._canvasShell_1xs2z_28{position:relative;overflow:hidden;flex:none;border:1px solid rgb(0 0 0 / 22%);background:var(--gc-paper, #f2f0ea);box-shadow:inset 0 0 0 1px #ffffff1f}._canvas_1xs2z_28{width:100%;height:100%}._canvas_1xs2z_28 canvas{display:block;width:100%;height:100%}._viewportLabels_1xs2z_48{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));pointer-events:none}._viewportLabels_1xs2z_48[data-layout=portrait]{grid-template-columns:1fr;grid-template-rows:repeat(2,minmax(0,1fr))}._splitLabel_1xs2z_61{display:grid;place-items:center;color:#111827d1;font-size:clamp(1.15rem,2.7vw,2.1rem);font-weight:700;font-family:IBM Plex Sans Condensed,Avenir Next Condensed,sans-serif;text-transform:uppercase;letter-spacing:.34em;text-shadow:0 2px 12px rgb(255 255 255 / 42%)}._controlOverlay_1xs2z_73{position:absolute;right:1rem;bottom:1rem;left:1rem;display:flex;justify-content:center;pointer-events:none}._resolutionCard_1xs2z_83{pointer-events:auto;display:flex;align-items:center;justify-content:center;width:min(100%,26rem);padding:.75rem .9rem;border:1px solid color-mix(in srgb,var(--gc-border, #34516f) 72%,transparent);border-radius:16px;background:#070f199e;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);box-shadow:0 10px 30px #0000002e}._resolutionControl_1xs2z_97{display:flex;align-items:center;gap:.85rem;width:100%;min-width:0}._slider_1xs2z_105{width:100%;accent-color:var(--gc-primary, #45c4b0);cursor:pointer}._sliderValue_1xs2z_111{min-width:3.75rem;text-align:right;font-family:IBM Plex Mono,JetBrains Mono,monospace;font-size:.95rem}@media (max-width: 900px){._resolutionControl_1xs2z_97{min-width:0}}@media (max-width: 720px){._wrapper_1xs2z_1{padding:0}._splitLabel_1xs2z_61{font-size:clamp(.95rem,5vw,1.4rem);letter-spacing:.24em}._controlOverlay_1xs2z_73{right:0rem;bottom:0rem;left:0rem}}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
import { jsx as pn, jsxs as yi } from "react/jsx-runtime";
import { useState as Ms, useRef as dr, useEffect as ai, useMemo as fr } from "react";
/**
 * @license
 * Copyright 2010-2023 Three.js Authors
 * SPDX-License-Identifier: MIT
 */
const ss = "160", Ln = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Pn = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, Yo = 0, Ss = 1, jo = 2, so = 1, ao = 2, jt = 3, un = 0, Mt = 1, Kt = 2, on = 0, $n = 1, Es = 2, ys = 3, Ts = 4, Ko = 5, Mn = 100, Zo = 101, $o = 102, bs = 103, As = 104, Jo = 200, Qo = 201, el = 202, tl = 203, Kr = 204, Zr = 205, nl = 206, il = 207, rl = 208, sl = 209, al = 210, ol = 211, ll = 212, cl = 213, ul = 214, hl = 0, dl = 1, fl = 2, $i = 3, pl = 4, ml = 5, _l = 6, gl = 7, oo = 0, vl = 1, xl = 2, ln = 0, Ml = 1, Sl = 2, El = 3, yl = 4, Tl = 5, bl = 6, lo = 300, Qn = 301, ei = 302, $r = 303, Jr = 304, rr = 306, Qr = 1e3, Nt = 1001, es = 1002, gt = 1003, ws = 1004, pr = 1005, Rt = 1006, Al = 1007, _i = 1008, cn = 1009, wl = 1010, Rl = 1011, as = 1012, co = 1013, sn = 1014, an = 1015, gi = 1016, uo = 1017, ho = 1018, En = 1020, Cl = 1021, Ft = 1023, Ll = 1024, Pl = 1025, yn = 1026, ti = 1027, Dl = 1028, fo = 1029, Ul = 1030, po = 1031, mo = 1033, mr = 33776, _r = 33777, gr = 33778, vr = 33779, Rs = 35840, Cs = 35841, Ls = 35842, Ps = 35843, _o = 36196, Ds = 37492, Us = 37496, Is = 37808, Ns = 37809, Fs = 37810, Os = 37811, Bs = 37812, zs = 37813, Gs = 37814, Hs = 37815, Vs = 37816, ks = 37817, Ws = 37818, Xs = 37819, qs = 37820, Ys = 37821, xr = 36492, js = 36494, Ks = 36495, Il = 36283, Zs = 36284, $s = 36285, Js = 36286, go = 3e3, Tn = 3001, Nl = 3200, Fl = 3201, vo = 0, Ol = 1, Ct = "", ht = "srgb", $t = "srgb-linear", os = "display-p3", sr = "display-p3-linear", Ji = "linear", Ze = "srgb", Qi = "rec709", er = "p3", Dn = 7680, Qs = 519, Bl = 512, zl = 513, Gl = 514, xo = 515, Hl = 516, Vl = 517, kl = 518, Wl = 519, ea = 35044, ta = "300 es", ts = 1035, Zt = 2e3, tr = 2001;
class Rn {
  addEventListener(e, t) {
    this._listeners === void 0 && (this._listeners = {});
    const n = this._listeners;
    n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);
  }
  hasEventListener(e, t) {
    if (this._listeners === void 0) return !1;
    const n = this._listeners;
    return n[e] !== void 0 && n[e].indexOf(t) !== -1;
  }
  removeEventListener(e, t) {
    if (this._listeners === void 0) return;
    const r = this._listeners[e];
    if (r !== void 0) {
      const s = r.indexOf(t);
      s !== -1 && r.splice(s, 1);
    }
  }
  dispatchEvent(e) {
    if (this._listeners === void 0) return;
    const n = this._listeners[e.type];
    if (n !== void 0) {
      e.target = this;
      const r = n.slice(0);
      for (let s = 0, o = r.length; s < o; s++)
        r[s].call(this, e);
      e.target = null;
    }
  }
}
const pt = ["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"], Ki = Math.PI / 180, ns = 180 / Math.PI;
function vi() {
  const i = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0;
  return (pt[i & 255] + pt[i >> 8 & 255] + pt[i >> 16 & 255] + pt[i >> 24 & 255] + "-" + pt[e & 255] + pt[e >> 8 & 255] + "-" + pt[e >> 16 & 15 | 64] + pt[e >> 24 & 255] + "-" + pt[t & 63 | 128] + pt[t >> 8 & 255] + "-" + pt[t >> 16 & 255] + pt[t >> 24 & 255] + pt[n & 255] + pt[n >> 8 & 255] + pt[n >> 16 & 255] + pt[n >> 24 & 255]).toLowerCase();
}
function vt(i, e, t) {
  return Math.max(e, Math.min(t, i));
}
function Xl(i, e) {
  return (i % e + e) % e;
}
function Mr(i, e, t) {
  return (1 - t) * i + t * e;
}
function na(i) {
  return (i & i - 1) === 0 && i !== 0;
}
function is(i) {
  return Math.pow(2, Math.floor(Math.log(i) / Math.LN2));
}
function oi(i, e) {
  switch (e.constructor) {
    case Float32Array:
      return i;
    case Uint32Array:
      return i / 4294967295;
    case Uint16Array:
      return i / 65535;
    case Uint8Array:
      return i / 255;
    case Int32Array:
      return Math.max(i / 2147483647, -1);
    case Int16Array:
      return Math.max(i / 32767, -1);
    case Int8Array:
      return Math.max(i / 127, -1);
    default:
      throw new Error("Invalid component type.");
  }
}
function xt(i, e) {
  switch (e.constructor) {
    case Float32Array:
      return i;
    case Uint32Array:
      return Math.round(i * 4294967295);
    case Uint16Array:
      return Math.round(i * 65535);
    case Uint8Array:
      return Math.round(i * 255);
    case Int32Array:
      return Math.round(i * 2147483647);
    case Int16Array:
      return Math.round(i * 32767);
    case Int8Array:
      return Math.round(i * 127);
    default:
      throw new Error("Invalid component type.");
  }
}
const ql = {
  DEG2RAD: Ki
};
class Ie {
  constructor(e = 0, t = 0) {
    Ie.prototype.isVector2 = !0, this.x = e, this.y = t;
  }
  get width() {
    return this.x;
  }
  set width(e) {
    this.x = e;
  }
  get height() {
    return this.y;
  }
  set height(e) {
    this.y = e;
  }
  set(e, t) {
    return this.x = e, this.y = t, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this;
  }
  divide(e) {
    return this.x /= e.x, this.y /= e.y, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  applyMatrix3(e) {
    const t = this.x, n = this.y, 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 = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y;
  }
  cross(e) {
    return this.x * e.y - this.y * e.x;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  angle() {
    return Math.atan2(-this.y, -this.x) + Math.PI;
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0) return Math.PI / 2;
    const n = this.dot(e) / t;
    return Math.acos(vt(n, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const t = this.x - e.x, n = this.y - e.y;
    return t * t + n * n;
  }
  manhattanDistanceTo(e) {
    return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;
  }
  lerpVectors(e, t, n) {
    return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this;
  }
  rotateAround(e, t) {
    const n = Math.cos(t), r = Math.sin(t), s = this.x - e.x, o = this.y - e.y;
    return this.x = s * n - o * r + e.x, this.y = s * r + o * n + e.y, this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y;
  }
}
class Ve {
  constructor(e, t, n, r, s, o, a, l, c) {
    Ve.prototype.isMatrix3 = !0, this.elements = [
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, n, r, s, o, a, l, c);
  }
  set(e, t, n, r, s, o, a, l, c) {
    const h = this.elements;
    return h[0] = e, h[1] = r, h[2] = a, h[3] = t, h[4] = s, h[5] = l, h[6] = n, h[7] = o, h[8] = c, this;
  }
  identity() {
    return this.set(
      1,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      1
    ), this;
  }
  copy(e) {
    const t = this.elements, n = e.elements;
    return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this;
  }
  extractBasis(e, t, n) {
    return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;
  }
  setFromMatrix4(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[4],
      t[8],
      t[1],
      t[5],
      t[9],
      t[2],
      t[6],
      t[10]
    ), this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const n = e.elements, r = t.elements, s = this.elements, o = n[0], a = n[3], l = n[6], c = n[1], h = n[4], d = n[7], p = n[2], m = n[5], g = n[8], v = r[0], f = r[3], u = r[6], b = r[1], S = r[4], R = r[7], D = r[2], C = r[5], A = r[8];
    return s[0] = o * v + a * b + l * D, s[3] = o * f + a * S + l * C, s[6] = o * u + a * R + l * A, s[1] = c * v + h * b + d * D, s[4] = c * f + h * S + d * C, s[7] = c * u + h * R + d * A, s[2] = p * v + m * b + g * D, s[5] = p * f + m * S + g * C, s[8] = p * u + m * R + g * A, this;
  }
  multiplyScalar(e) {
    const t = this.elements;
    return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this;
  }
  determinant() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8];
    return t * o * h - t * a * c - n * s * h + n * a * l + r * s * c - r * o * l;
  }
  invert() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], d = h * o - a * c, p = a * l - h * s, m = c * s - o * l, g = t * d + n * p + r * m;
    if (g === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
    const v = 1 / g;
    return e[0] = d * v, e[1] = (r * c - h * n) * v, e[2] = (a * n - r * o) * v, e[3] = p * v, e[4] = (h * t - r * l) * v, e[5] = (r * s - a * t) * v, e[6] = m * v, e[7] = (n * l - c * t) * v, e[8] = (o * t - n * s) * v, this;
  }
  transpose() {
    let e;
    const t = this.elements;
    return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this;
  }
  getNormalMatrix(e) {
    return this.setFromMatrix4(e).invert().transpose();
  }
  transposeIntoArray(e) {
    const t = this.elements;
    return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this;
  }
  setUvTransform(e, t, n, r, s, o, a) {
    const l = Math.cos(s), c = Math.sin(s);
    return this.set(
      n * l,
      n * c,
      -n * (l * o + c * a) + o + e,
      -r * c,
      r * l,
      -r * (-c * o + l * a) + a + t,
      0,
      0,
      1
    ), this;
  }
  //
  scale(e, t) {
    return this.premultiply(Sr.makeScale(e, t)), this;
  }
  rotate(e) {
    return this.premultiply(Sr.makeRotation(-e)), this;
  }
  translate(e, t) {
    return this.premultiply(Sr.makeTranslation(e, t)), this;
  }
  // for 2D Transforms
  makeTranslation(e, t) {
    return e.isVector2 ? this.set(
      1,
      0,
      e.x,
      0,
      1,
      e.y,
      0,
      0,
      1
    ) : this.set(
      1,
      0,
      e,
      0,
      1,
      t,
      0,
      0,
      1
    ), this;
  }
  makeRotation(e) {
    const t = Math.cos(e), n = Math.sin(e);
    return this.set(
      t,
      -n,
      0,
      n,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  makeScale(e, t) {
    return this.set(
      e,
      0,
      0,
      0,
      t,
      0,
      0,
      0,
      1
    ), this;
  }
  //
  equals(e) {
    const t = this.elements, n = e.elements;
    for (let r = 0; r < 9; r++)
      if (t[r] !== n[r]) return !1;
    return !0;
  }
  fromArray(e, t = 0) {
    for (let n = 0; n < 9; n++)
      this.elements[n] = e[n + t];
    return this;
  }
  toArray(e = [], t = 0) {
    const n = this.elements;
    return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e;
  }
  clone() {
    return new this.constructor().fromArray(this.elements);
  }
}
const Sr = /* @__PURE__ */ new Ve();
function Mo(i) {
  for (let e = i.length - 1; e >= 0; --e)
    if (i[e] >= 65535) return !0;
  return !1;
}
function nr(i) {
  return document.createElementNS("http://www.w3.org/1999/xhtml", i);
}
function Yl() {
  const i = nr("canvas");
  return i.style.display = "block", i;
}
const ia = {};
function mi(i) {
  i in ia || (ia[i] = !0, console.warn(i));
}
const ra = /* @__PURE__ */ new Ve().set(
  0.8224621,
  0.177538,
  0,
  0.0331941,
  0.9668058,
  0,
  0.0170827,
  0.0723974,
  0.9105199
), sa = /* @__PURE__ */ new Ve().set(
  1.2249401,
  -0.2249404,
  0,
  -0.0420569,
  1.0420571,
  0,
  -0.0196376,
  -0.0786361,
  1.0982735
), Ti = {
  [$t]: {
    transfer: Ji,
    primaries: Qi,
    toReference: (i) => i,
    fromReference: (i) => i
  },
  [ht]: {
    transfer: Ze,
    primaries: Qi,
    toReference: (i) => i.convertSRGBToLinear(),
    fromReference: (i) => i.convertLinearToSRGB()
  },
  [sr]: {
    transfer: Ji,
    primaries: er,
    toReference: (i) => i.applyMatrix3(sa),
    fromReference: (i) => i.applyMatrix3(ra)
  },
  [os]: {
    transfer: Ze,
    primaries: er,
    toReference: (i) => i.convertSRGBToLinear().applyMatrix3(sa),
    fromReference: (i) => i.applyMatrix3(ra).convertLinearToSRGB()
  }
}, jl = /* @__PURE__ */ new Set([$t, sr]), Ke = {
  enabled: !0,
  _workingColorSpace: $t,
  get workingColorSpace() {
    return this._workingColorSpace;
  },
  set workingColorSpace(i) {
    if (!jl.has(i))
      throw new Error(`Unsupported working color space, "${i}".`);
    this._workingColorSpace = i;
  },
  convert: function(i, e, t) {
    if (this.enabled === !1 || e === t || !e || !t)
      return i;
    const n = Ti[e].toReference, r = Ti[t].fromReference;
    return r(n(i));
  },
  fromWorkingColorSpace: function(i, e) {
    return this.convert(i, this._workingColorSpace, e);
  },
  toWorkingColorSpace: function(i, e) {
    return this.convert(i, e, this._workingColorSpace);
  },
  getPrimaries: function(i) {
    return Ti[i].primaries;
  },
  getTransfer: function(i) {
    return i === Ct ? Ji : Ti[i].transfer;
  }
};
function Jn(i) {
  return i < 0.04045 ? i * 0.0773993808 : Math.pow(i * 0.9478672986 + 0.0521327014, 2.4);
}
function Er(i) {
  return i < 31308e-7 ? i * 12.92 : 1.055 * Math.pow(i, 0.41666) - 0.055;
}
let Un;
class So {
  static getDataURL(e) {
    if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u")
      return e.src;
    let t;
    if (e instanceof HTMLCanvasElement)
      t = e;
    else {
      Un === void 0 && (Un = nr("canvas")), Un.width = e.width, Un.height = e.height;
      const n = Un.getContext("2d");
      e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = Un;
    }
    return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.toDataURL("image/png");
  }
  static sRGBToLinear(e) {
    if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
      const t = nr("canvas");
      t.width = e.width, t.height = e.height;
      const n = t.getContext("2d");
      n.drawImage(e, 0, 0, e.width, e.height);
      const r = n.getImageData(0, 0, e.width, e.height), s = r.data;
      for (let o = 0; o < s.length; o++)
        s[o] = Jn(s[o] / 255) * 255;
      return n.putImageData(r, 0, 0), t;
    } else if (e.data) {
      const t = e.data.slice(0);
      for (let n = 0; n < t.length; n++)
        t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(Jn(t[n] / 255) * 255) : t[n] = Jn(t[n]);
      return {
        data: t,
        width: e.width,
        height: e.height
      };
    } else
      return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
  }
}
let Kl = 0;
class Eo {
  constructor(e = null) {
    this.isSource = !0, Object.defineProperty(this, "id", { value: Kl++ }), this.uuid = vi(), this.data = e, this.version = 0;
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.images[this.uuid] !== void 0)
      return e.images[this.uuid];
    const n = {
      uuid: this.uuid,
      url: ""
    }, r = this.data;
    if (r !== null) {
      let s;
      if (Array.isArray(r)) {
        s = [];
        for (let o = 0, a = r.length; o < a; o++)
          r[o].isDataTexture ? s.push(yr(r[o].image)) : s.push(yr(r[o]));
      } else
        s = yr(r);
      n.url = s;
    }
    return t || (e.images[this.uuid] = n), n;
  }
}
function yr(i) {
  return typeof HTMLImageElement < "u" && i instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && i instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && i instanceof ImageBitmap ? So.getDataURL(i) : i.data ? {
    data: Array.from(i.data),
    width: i.width,
    height: i.height,
    type: i.data.constructor.name
  } : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let Zl = 0;
class bt extends Rn {
  constructor(e = bt.DEFAULT_IMAGE, t = bt.DEFAULT_MAPPING, n = Nt, r = Nt, s = Rt, o = _i, a = Ft, l = cn, c = bt.DEFAULT_ANISOTROPY, h = Ct) {
    super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: Zl++ }), this.uuid = vi(), this.name = "", this.source = new Eo(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = r, this.magFilter = s, this.minFilter = o, this.anisotropy = c, this.format = a, this.internalFormat = null, this.type = l, this.offset = new Ie(0, 0), this.repeat = new Ie(1, 1), this.center = new Ie(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Ve(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, typeof h == "string" ? this.colorSpace = h : (mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = h === Tn ? ht : Ct), this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.needsPMREMUpdate = !1;
  }
  get image() {
    return this.source.data;
  }
  set image(e = null) {
    this.source.data = e;
  }
  updateMatrix() {
    this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    if (!t && e.textures[this.uuid] !== void 0)
      return e.textures[this.uuid];
    const n = {
      metadata: {
        version: 4.6,
        type: "Texture",
        generator: "Texture.toJSON"
      },
      uuid: this.uuid,
      name: this.name,
      image: this.source.toJSON(e).uuid,
      mapping: this.mapping,
      channel: this.channel,
      repeat: [this.repeat.x, this.repeat.y],
      offset: [this.offset.x, this.offset.y],
      center: [this.center.x, this.center.y],
      rotation: this.rotation,
      wrap: [this.wrapS, this.wrapT],
      format: this.format,
      internalFormat: this.internalFormat,
      type: this.type,
      colorSpace: this.colorSpace,
      minFilter: this.minFilter,
      magFilter: this.magFilter,
      anisotropy: this.anisotropy,
      flipY: this.flipY,
      generateMipmaps: this.generateMipmaps,
      premultiplyAlpha: this.premultiplyAlpha,
      unpackAlignment: this.unpackAlignment
    };
    return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  transformUv(e) {
    if (this.mapping !== lo) return e;
    if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)
      switch (this.wrapS) {
        case Qr:
          e.x = e.x - Math.floor(e.x);
          break;
        case Nt:
          e.x = e.x < 0 ? 0 : 1;
          break;
        case es:
          Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);
          break;
      }
    if (e.y < 0 || e.y > 1)
      switch (this.wrapT) {
        case Qr:
          e.y = e.y - Math.floor(e.y);
          break;
        case Nt:
          e.y = e.y < 0 ? 0 : 1;
          break;
        case es:
          Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);
          break;
      }
    return this.flipY && (e.y = 1 - e.y), e;
  }
  set needsUpdate(e) {
    e === !0 && (this.version++, this.source.needsUpdate = !0);
  }
  get encoding() {
    return mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace === ht ? Tn : go;
  }
  set encoding(e) {
    mi("THREE.Texture: Property .encoding has been replaced by .colorSpace."), this.colorSpace = e === Tn ? ht : Ct;
  }
}
bt.DEFAULT_IMAGE = null;
bt.DEFAULT_MAPPING = lo;
bt.DEFAULT_ANISOTROPY = 1;
class $e {
  constructor(e = 0, t = 0, n = 0, r = 1) {
    $e.prototype.isVector4 = !0, 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 new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      case 3:
        return this.w;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z, this.w);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this.w += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;
  }
  applyMatrix4(e) {
    const t = this.x, n = this.y, r = this.z, s = this.w, o = e.elements;
    return this.x = o[0] * t + o[4] * n + o[8] * r + o[12] * s, this.y = o[1] * t + o[5] * n + o[9] * r + o[13] * s, this.z = o[2] * t + o[6] * n + o[10] * r + o[14] * s, this.w = o[3] * t + o[7] * n + o[11] * r + o[15] * s, this;
  }
  divideScalar(e) {
    return this.multiplyScalar(1 / e);
  }
  setAxisAngleFromQuaternion(e) {
    this.w = 2 * Math.acos(e.w);
    const t = Math.sqrt(1 - e.w * e.w);
    return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;
  }
  setAxisAngleFromRotationMatrix(e) {
    let t, n, r, s;
    const l = e.elements, c = l[0], h = l[4], d = l[8], p = l[1], m = l[5], g = l[9], v = l[2], f = l[6], u = l[10];
    if (Math.abs(h - p) < 0.01 && Math.abs(d - v) < 0.01 && Math.abs(g - f) < 0.01) {
      if (Math.abs(h + p) < 0.1 && Math.abs(d + v) < 0.1 && Math.abs(g + f) < 0.1 && Math.abs(c + m + u - 3) < 0.1)
        return this.set(1, 0, 0, 0), this;
      t = Math.PI;
      const S = (c + 1) / 2, R = (m + 1) / 2, D = (u + 1) / 2, C = (h + p) / 4, A = (d + v) / 4, W = (g + f) / 4;
      return S > R && S > D ? S < 0.01 ? (n = 0, r = 0.707106781, s = 0.707106781) : (n = Math.sqrt(S), r = C / n, s = A / n) : R > D ? R < 0.01 ? (n = 0.707106781, r = 0, s = 0.707106781) : (r = Math.sqrt(R), n = C / r, s = W / r) : D < 0.01 ? (n = 0.707106781, r = 0.707106781, s = 0) : (s = Math.sqrt(D), n = A / s, r = W / s), this.set(n, r, s, t), this;
    }
    let b = Math.sqrt((f - g) * (f - g) + (d - v) * (d - v) + (p - h) * (p - h));
    return Math.abs(b) < 1e-3 && (b = 1), this.x = (f - g) / b, this.y = (d - v) / b, this.z = (p - h) / b, this.w = Math.acos((c + m + u - 1) / 2), this;
  }
  min(e) {
    return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this;
  }
  max(e) {
    return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this;
  }
  clamp(e, t) {
    return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;
  }
  ceil() {
    return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;
  }
  round() {
    return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;
  }
  roundToZero() {
    return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;
  }
  negate() {
    return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
  }
  dot(e) {
    return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
  }
  lengthSq() {
    return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
  }
  length() {
    return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  }
  manhattanLength() {
    return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
  }
  normalize() {
    return this.divideScalar(this.length() || 1);
  }
  setLength(e) {
    return this.normalize().multiplyScalar(e);
  }
  lerp(e, t) {
    return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this;
  }
  lerpVectors(e, t, n) {
    return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this;
  }
  equals(e) {
    return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
  }
  fromArray(e, t = 0) {
    return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e;
  }
  fromBufferAttribute(e, t) {
    return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this;
  }
  random() {
    return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z, yield this.w;
  }
}
class $l extends Rn {
  constructor(e = 1, t = 1, n = {}) {
    super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new $e(0, 0, e, t), this.scissorTest = !1, this.viewport = new $e(0, 0, e, t);
    const r = { width: e, height: t, depth: 1 };
    n.encoding !== void 0 && (mi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."), n.colorSpace = n.encoding === Tn ? ht : Ct), n = Object.assign({
      generateMipmaps: !1,
      internalFormat: null,
      minFilter: Rt,
      depthBuffer: !0,
      stencilBuffer: !1,
      depthTexture: null,
      samples: 0
    }, n), this.texture = new bt(r, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.flipY = !1, this.texture.generateMipmaps = n.generateMipmaps, this.texture.internalFormat = n.internalFormat, this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples;
  }
  setSize(e, t, n = 1) {
    (this.width !== e || this.height !== t || this.depth !== n) && (this.width = e, this.height = t, this.depth = n, this.texture.image.width = e, this.texture.image.height = t, this.texture.image.depth = n, this.dispose()), this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.texture = e.texture.clone(), this.texture.isRenderTargetTexture = !0;
    const t = Object.assign({}, e.texture.image);
    return this.texture.source = new Eo(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class bn extends $l {
  constructor(e = 1, t = 1, n = {}) {
    super(e, t, n), this.isWebGLRenderTarget = !0;
  }
}
class yo extends bt {
  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 = gt, this.minFilter = gt, this.wrapR = Nt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class Jl extends bt {
  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 = gt, this.minFilter = gt, this.wrapR = Nt, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
  }
}
class An {
  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, s, o, a) {
    let l = n[r + 0], c = n[r + 1], h = n[r + 2], d = n[r + 3];
    const p = s[o + 0], m = s[o + 1], g = s[o + 2], v = s[o + 3];
    if (a === 0) {
      e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = d;
      return;
    }
    if (a === 1) {
      e[t + 0] = p, e[t + 1] = m, e[t + 2] = g, e[t + 3] = v;
      return;
    }
    if (d !== v || l !== p || c !== m || h !== g) {
      let f = 1 - a;
      const u = l * p + c * m + h * g + d * v, b = u >= 0 ? 1 : -1, S = 1 - u * u;
      if (S > Number.EPSILON) {
        const D = Math.sqrt(S), C = Math.atan2(D, u * b);
        f = Math.sin(f * C) / D, a = Math.sin(a * C) / D;
      }
      const R = a * b;
      if (l = l * f + p * R, c = c * f + m * R, h = h * f + g * R, d = d * f + v * R, f === 1 - a) {
        const D = 1 / Math.sqrt(l * l + c * c + h * h + d * d);
        l *= D, c *= D, h *= D, d *= D;
      }
    }
    e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = d;
  }
  static multiplyQuaternionsFlat(e, t, n, r, s, o) {
    const a = n[r], l = n[r + 1], c = n[r + 2], h = n[r + 3], d = s[o], p = s[o + 1], m = s[o + 2], g = s[o + 3];
    return e[t] = a * g + h * d + l * m - c * p, e[t + 1] = l * g + h * p + c * d - a * m, e[t + 2] = c * g + h * m + a * p - l * d, e[t + 3] = h * g - a * d - l * p - c * m, 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) {
    const n = e._x, r = e._y, s = e._z, o = e._order, a = Math.cos, l = Math.sin, c = a(n / 2), h = a(r / 2), d = a(s / 2), p = l(n / 2), m = l(r / 2), g = l(s / 2);
    switch (o) {
      case "XYZ":
        this._x = p * h * d + c * m * g, this._y = c * m * d - p * h * g, this._z = c * h * g + p * m * d, this._w = c * h * d - p * m * g;
        break;
      case "YXZ":
        this._x = p * h * d + c * m * g, this._y = c * m * d - p * h * g, this._z = c * h * g - p * m * d, this._w = c * h * d + p * m * g;
        break;
      case "ZXY":
        this._x = p * h * d - c * m * g, this._y = c * m * d + p * h * g, this._z = c * h * g + p * m * d, this._w = c * h * d - p * m * g;
        break;
      case "ZYX":
        this._x = p * h * d - c * m * g, this._y = c * m * d + p * h * g, this._z = c * h * g - p * m * d, this._w = c * h * d + p * m * g;
        break;
      case "YZX":
        this._x = p * h * d + c * m * g, this._y = c * m * d + p * h * g, this._z = c * h * g - p * m * d, this._w = c * h * d - p * m * g;
        break;
      case "XZY":
        this._x = p * h * d - c * m * g, this._y = c * m * d - p * h * g, this._z = c * h * g + p * m * d, this._w = c * h * d + p * m * g;
        break;
      default:
        console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + o);
    }
    return t === !0 && this._onChangeCallback(), this;
  }
  setFromAxisAngle(e, t) {
    const n = t / 2, 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) {
    const t = e.elements, n = t[0], r = t[4], s = t[8], o = t[1], a = t[5], l = t[9], c = t[2], h = t[6], d = t[10], p = n + a + d;
    if (p > 0) {
      const m = 0.5 / Math.sqrt(p + 1);
      this._w = 0.25 / m, this._x = (h - l) * m, this._y = (s - c) * m, this._z = (o - r) * m;
    } else if (n > a && n > d) {
      const m = 2 * Math.sqrt(1 + n - a - d);
      this._w = (h - l) / m, this._x = 0.25 * m, this._y = (r + o) / m, this._z = (s + c) / m;
    } else if (a > d) {
      const m = 2 * Math.sqrt(1 + a - n - d);
      this._w = (s - c) / m, this._x = (r + o) / m, this._y = 0.25 * m, this._z = (l + h) / m;
    } else {
      const m = 2 * Math.sqrt(1 + d - n - a);
      this._w = (o - r) / m, this._x = (s + c) / m, this._y = (l + h) / m, this._z = 0.25 * m;
    }
    return this._onChangeCallback(), this;
  }
  setFromUnitVectors(e, t) {
    let n = e.dot(t) + 1;
    return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize();
  }
  angleTo(e) {
    return 2 * Math.acos(Math.abs(vt(this.dot(e), -1, 1)));
  }
  rotateTowards(e, t) {
    const n = this.angleTo(e);
    if (n === 0) return this;
    const 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 = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;
  }
  multiply(e) {
    return this.multiplyQuaternions(this, e);
  }
  premultiply(e) {
    return this.multiplyQuaternions(e, this);
  }
  multiplyQuaternions(e, t) {
    const n = e._x, r = e._y, s = e._z, o = e._w, a = t._x, l = t._y, c = t._z, h = t._w;
    return this._x = n * h + o * a + r * c - s * l, this._y = r * h + o * l + s * a - n * c, this._z = s * h + o * c + n * l - r * a, this._w = o * h - n * a - r * l - s * c, this._onChangeCallback(), this;
  }
  slerp(e, t) {
    if (t === 0) return this;
    if (t === 1) return this.copy(e);
    const n = this._x, r = this._y, s = this._z, o = this._w;
    let a = o * e._w + n * e._x + r * e._y + s * e._z;
    if (a < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, a = -a) : this.copy(e), a >= 1)
      return this._w = o, this._x = n, this._y = r, this._z = s, this;
    const l = 1 - a * a;
    if (l <= Number.EPSILON) {
      const m = 1 - t;
      return this._w = m * o + t * this._w, this._x = m * n + t * this._x, this._y = m * r + t * this._y, this._z = m * s + t * this._z, this.normalize(), this;
    }
    const c = Math.sqrt(l), h = Math.atan2(c, a), d = Math.sin((1 - t) * h) / c, p = Math.sin(t * h) / c;
    return this._w = o * d + this._w * p, this._x = n * d + this._x * p, this._y = r * d + this._y * p, this._z = s * d + this._z * p, this._onChangeCallback(), this;
  }
  slerpQuaternions(e, t, n) {
    return this.copy(e).slerp(t, n);
  }
  random() {
    const e = Math.random(), t = Math.sqrt(1 - e), n = Math.sqrt(e), r = 2 * Math.PI * Math.random(), s = 2 * Math.PI * Math.random();
    return this.set(
      t * Math.cos(r),
      n * Math.sin(s),
      n * Math.cos(s),
      t * Math.sin(r)
    );
  }
  equals(e) {
    return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
  }
  fromArray(e, t = 0) {
    return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;
  }
  toArray(e = [], t = 0) {
    return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;
  }
  fromBufferAttribute(e, t) {
    return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this;
  }
  toJSON() {
    return this.toArray();
  }
  _onChange(e) {
    return this._onChangeCallback = e, this;
  }
  _onChangeCallback() {
  }
  *[Symbol.iterator]() {
    yield this._x, yield this._y, yield this._z, yield this._w;
  }
}
class P {
  constructor(e = 0, t = 0, n = 0) {
    P.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n;
  }
  set(e, t, n) {
    return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;
  }
  setScalar(e) {
    return this.x = e, this.y = e, this.z = e, this;
  }
  setX(e) {
    return this.x = e, this;
  }
  setY(e) {
    return this.y = e, this;
  }
  setZ(e) {
    return this.z = e, this;
  }
  setComponent(e, t) {
    switch (e) {
      case 0:
        this.x = t;
        break;
      case 1:
        this.y = t;
        break;
      case 2:
        this.z = t;
        break;
      default:
        throw new Error("index is out of range: " + e);
    }
    return this;
  }
  getComponent(e) {
    switch (e) {
      case 0:
        return this.x;
      case 1:
        return this.y;
      case 2:
        return this.z;
      default:
        throw new Error("index is out of range: " + e);
    }
  }
  clone() {
    return new this.constructor(this.x, this.y, this.z);
  }
  copy(e) {
    return this.x = e.x, this.y = e.y, this.z = e.z, this;
  }
  add(e) {
    return this.x += e.x, this.y += e.y, this.z += e.z, this;
  }
  addScalar(e) {
    return this.x += e, this.y += e, this.z += e, this;
  }
  addVectors(e, t) {
    return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
  }
  addScaledVector(e, t) {
    return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
  }
  sub(e) {
    return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
  }
  subScalar(e) {
    return this.x -= e, this.y -= e, this.z -= e, this;
  }
  subVectors(e, t) {
    return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
  }
  multiply(e) {
    return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
  }
  multiplyScalar(e) {
    return this.x *= e, this.y *= e, this.z *= e, this;
  }
  multiplyVectors(e, t) {
    return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
  }
  applyEuler(e) {
    return this.applyQuaternion(aa.setFromEuler(e));
  }
  applyAxisAngle(e, t) {
    return this.applyQuaternion(aa.setFromAxisAngle(e, t));
  }
  applyMatrix3(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements;
    return this.x = s[0] * t + s[3] * n + s[6] * r, this.y = s[1] * t + s[4] * n + s[7] * r, this.z = s[2] * t + s[5] * n + s[8] * r, this;
  }
  applyNormalMatrix(e) {
    return this.applyMatrix3(e).normalize();
  }
  applyMatrix4(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements, o = 1 / (s[3] * t + s[7] * n + s[11] * r + s[15]);
    return this.x = (s[0] * t + s[4] * n + s[8] * r + s[12]) * o, this.y = (s[1] * t + s[5] * n + s[9] * r + s[13]) * o, this.z = (s[2] * t + s[6] * n + s[10] * r + s[14]) * o, this;
  }
  applyQuaternion(e) {
    const t = this.x, n = this.y, r = this.z, s = e.x, o = e.y, a = e.z, l = e.w, c = 2 * (o * r - a * n), h = 2 * (a * t - s * r), d = 2 * (s * n - o * t);
    return this.x = t + l * c + o * d - a * h, this.y = n + l * h + a * c - s * d, this.z = r + l * d + s * h - o * c, this;
  }
  project(e) {
    return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
  }
  unproject(e) {
    return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
  }
  transformDirection(e) {
    const t = this.x, n = this.y, r = this.z, s = e.elements;
    return this.x = s[0] * t + s[4] * n + s[8] * r, this.y = s[1] * t + s[5] * n + s[9] * r, this.z = s[2] * t + s[6] * n + s[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 = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this;
  }
  clampScalar(e, t) {
    return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this;
  }
  clampLength(e, t) {
    const n = this.length();
    return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
  }
  floor() {
    return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
  }
  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;
  }
  // TODO lengthSquared?
  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) {
    const n = e.x, r = e.y, s = e.z, o = t.x, a = t.y, l = t.z;
    return this.x = r * l - s * a, this.y = s * o - n * l, this.z = n * a - r * o, this;
  }
  projectOnVector(e) {
    const t = e.lengthSq();
    if (t === 0) return this.set(0, 0, 0);
    const n = e.dot(this) / t;
    return this.copy(e).multiplyScalar(n);
  }
  projectOnPlane(e) {
    return Tr.copy(this).projectOnVector(e), this.sub(Tr);
  }
  reflect(e) {
    return this.sub(Tr.copy(e).multiplyScalar(2 * this.dot(e)));
  }
  angleTo(e) {
    const t = Math.sqrt(this.lengthSq() * e.lengthSq());
    if (t === 0) return Math.PI / 2;
    const n = this.dot(e) / t;
    return Math.acos(vt(n, -1, 1));
  }
  distanceTo(e) {
    return Math.sqrt(this.distanceToSquared(e));
  }
  distanceToSquared(e) {
    const 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) {
    const 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) {
    const t = e.elements;
    return this.x = t[12], this.y = t[13], this.z = t[14], this;
  }
  setFromMatrixScale(e) {
    const 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() {
    const e = (Math.random() - 0.5) * 2, t = Math.random() * Math.PI * 2, n = Math.sqrt(1 - e ** 2);
    return this.x = n * Math.cos(t), this.y = n * Math.sin(t), this.z = e, this;
  }
  *[Symbol.iterator]() {
    yield this.x, yield this.y, yield this.z;
  }
}
const Tr = /* @__PURE__ */ new P(), aa = /* @__PURE__ */ new An();
class Cn {
  constructor(e = new P(1 / 0, 1 / 0, 1 / 0), t = new P(-1 / 0, -1 / 0, -1 / 0)) {
    this.isBox3 = !0, this.min = e, this.max = t;
  }
  set(e, t) {
    return this.min.copy(e), this.max.copy(t), this;
  }
  setFromArray(e) {
    this.makeEmpty();
    for (let t = 0, n = e.length; t < n; t += 3)
      this.expandByPoint(Lt.fromArray(e, t));
    return this;
  }
  setFromBufferAttribute(e) {
    this.makeEmpty();
    for (let t = 0, n = e.count; t < n; t++)
      this.expandByPoint(Lt.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) {
    const n = Lt.copy(t).multiplyScalar(0.5);
    return this.min.copy(e).sub(n), this.max.copy(e).add(n), this;
  }
  setFromObject(e, t = !1) {
    return this.makeEmpty(), this.expandByObject(e, t);
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    return this.min.copy(e.min), this.max.copy(e.max), this;
  }
  makeEmpty() {
    return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
  }
  isEmpty() {
    return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
  }
  getCenter(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
  }
  getSize(e) {
    return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);
  }
  expandByPoint(e) {
    return this.min.min(e), this.max.max(e), this;
  }
  expandByVector(e) {
    return this.min.sub(e), this.max.add(e), this;
  }
  expandByScalar(e) {
    return this.min.addScalar(-e), this.max.addScalar(e), this;
  }
  expandByObject(e, t = !1) {
    e.updateWorldMatrix(!1, !1);
    const n = e.geometry;
    if (n !== void 0) {
      const s = n.getAttribute("position");
      if (t === !0 && s !== void 0 && e.isInstancedMesh !== !0)
        for (let o = 0, a = s.count; o < a; o++)
          e.isMesh === !0 ? e.getVertexPosition(o, Lt) : Lt.fromBufferAttribute(s, o), Lt.applyMatrix4(e.matrixWorld), this.expandByPoint(Lt);
      else
        e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), bi.copy(e.boundingBox)) : (n.boundingBox === null && n.computeBoundingBox(), bi.copy(n.boundingBox)), bi.applyMatrix4(e.matrixWorld), this.union(bi);
    }
    const r = e.children;
    for (let s = 0, o = r.length; s < o; s++)
      this.expandByObject(r[s], t);
    return this;
  }
  containsPoint(e) {
    return !(e.x < this.min.x || e.x > this.max.x || e.y < this.min.y || e.y > this.max.y || e.z < this.min.z || e.z > this.max.z);
  }
  containsBox(e) {
    return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z;
  }
  getParameter(e, t) {
    return t.set(
      (e.x - this.min.x) / (this.max.x - this.min.x),
      (e.y - this.min.y) / (this.max.y - this.min.y),
      (e.z - this.min.z) / (this.max.z - this.min.z)
    );
  }
  intersectsBox(e) {
    return !(e.max.x < this.min.x || e.min.x > this.max.x || e.max.y < this.min.y || e.min.y > this.max.y || e.max.z < this.min.z || e.min.z > this.max.z);
  }
  intersectsSphere(e) {
    return this.clampPoint(e.center, Lt), Lt.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(li), Ai.subVectors(this.max, li), In.subVectors(e.a, li), Nn.subVectors(e.b, li), Fn.subVectors(e.c, li), Jt.subVectors(Nn, In), Qt.subVectors(Fn, Nn), mn.subVectors(In, Fn);
    let t = [
      0,
      -Jt.z,
      Jt.y,
      0,
      -Qt.z,
      Qt.y,
      0,
      -mn.z,
      mn.y,
      Jt.z,
      0,
      -Jt.x,
      Qt.z,
      0,
      -Qt.x,
      mn.z,
      0,
      -mn.x,
      -Jt.y,
      Jt.x,
      0,
      -Qt.y,
      Qt.x,
      0,
      -mn.y,
      mn.x,
      0
    ];
    return !br(t, In, Nn, Fn, Ai) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !br(t, In, Nn, Fn, Ai)) ? !1 : (wi.crossVectors(Jt, Qt), t = [wi.x, wi.y, wi.z], br(t, In, Nn, Fn, Ai));
  }
  clampPoint(e, t) {
    return t.copy(e).clamp(this.min, this.max);
  }
  distanceToPoint(e) {
    return this.clampPoint(e, Lt).distanceTo(e);
  }
  getBoundingSphere(e) {
    return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(Lt).length() * 0.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 : (kt[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), kt[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), kt[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), kt[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), kt[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), kt[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), kt[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), kt[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(kt), 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);
  }
}
const kt = [
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P(),
  /* @__PURE__ */ new P()
], Lt = /* @__PURE__ */ new P(), bi = /* @__PURE__ */ new Cn(), In = /* @__PURE__ */ new P(), Nn = /* @__PURE__ */ new P(), Fn = /* @__PURE__ */ new P(), Jt = /* @__PURE__ */ new P(), Qt = /* @__PURE__ */ new P(), mn = /* @__PURE__ */ new P(), li = /* @__PURE__ */ new P(), Ai = /* @__PURE__ */ new P(), wi = /* @__PURE__ */ new P(), _n = /* @__PURE__ */ new P();
function br(i, e, t, n, r) {
  for (let s = 0, o = i.length - 3; s <= o; s += 3) {
    _n.fromArray(i, s);
    const a = r.x * Math.abs(_n.x) + r.y * Math.abs(_n.y) + r.z * Math.abs(_n.z), l = e.dot(_n), c = t.dot(_n), h = n.dot(_n);
    if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > a)
      return !1;
  }
  return !0;
}
const Ql = /* @__PURE__ */ new Cn(), ci = /* @__PURE__ */ new P(), Ar = /* @__PURE__ */ new P();
class xi {
  constructor(e = new P(), 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) {
    const n = this.center;
    t !== void 0 ? n.copy(t) : Ql.setFromPoints(e).getCenter(n);
    let r = 0;
    for (let s = 0, o = e.length; s < o; s++)
      r = Math.max(r, n.distanceToSquared(e[s]));
    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) {
    const 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) {
    const 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 = 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;
    ci.subVectors(e, this.center);
    const t = ci.lengthSq();
    if (t > this.radius * this.radius) {
      const n = Math.sqrt(t), r = (n - this.radius) * 0.5;
      this.center.addScaledVector(ci, r / n), this.radius += r;
    }
    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) : (Ar.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(ci.copy(e.center).add(Ar)), this.expandByPoint(ci.copy(e.center).sub(Ar))), this);
  }
  equals(e) {
    return e.center.equals(this.center) && e.radius === this.radius;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const Wt = /* @__PURE__ */ new P(), wr = /* @__PURE__ */ new P(), Ri = /* @__PURE__ */ new P(), en = /* @__PURE__ */ new P(), Rr = /* @__PURE__ */ new P(), Ci = /* @__PURE__ */ new P(), Cr = /* @__PURE__ */ new P();
class To {
  constructor(e = new P(), t = new P(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, Wt)), this;
  }
  closestPointToPoint(e, t) {
    t.subVectors(e, this.origin);
    const 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) {
    const t = Wt.subVectors(e, this.origin).dot(this.direction);
    return t < 0 ? this.origin.distanceToSquared(e) : (Wt.copy(this.origin).addScaledVector(this.direction, t), Wt.distanceToSquared(e));
  }
  distanceSqToSegment(e, t, n, r) {
    wr.copy(e).add(t).multiplyScalar(0.5), Ri.copy(t).sub(e).normalize(), en.copy(this.origin).sub(wr);
    const s = e.distanceTo(t) * 0.5, o = -this.direction.dot(Ri), a = en.dot(this.direction), l = -en.dot(Ri), c = en.lengthSq(), h = Math.abs(1 - o * o);
    let d, p, m, g;
    if (h > 0)
      if (d = o * l - a, p = o * a - l, g = s * h, d >= 0)
        if (p >= -g)
          if (p <= g) {
            const v = 1 / h;
            d *= v, p *= v, m = d * (d + o * p + 2 * a) + p * (o * d + p + 2 * l) + c;
          } else
            p = s, d = Math.max(0, -(o * p + a)), m = -d * d + p * (p + 2 * l) + c;
        else
          p = -s, d = Math.max(0, -(o * p + a)), m = -d * d + p * (p + 2 * l) + c;
      else
        p <= -g ? (d = Math.max(0, -(-o * s + a)), p = d > 0 ? -s : Math.min(Math.max(-s, -l), s), m = -d * d + p * (p + 2 * l) + c) : p <= g ? (d = 0, p = Math.min(Math.max(-s, -l), s), m = p * (p + 2 * l) + c) : (d = Math.max(0, -(o * s + a)), p = d > 0 ? s : Math.min(Math.max(-s, -l), s), m = -d * d + p * (p + 2 * l) + c);
    else
      p = o > 0 ? -s : s, d = Math.max(0, -(o * p + a)), m = -d * d + p * (p + 2 * l) + c;
    return n && n.copy(this.origin).addScaledVector(this.direction, d), r && r.copy(wr).addScaledVector(Ri, p), m;
  }
  intersectSphere(e, t) {
    Wt.subVectors(e.center, this.origin);
    const n = Wt.dot(this.direction), r = Wt.dot(Wt) - n * n, s = e.radius * e.radius;
    if (r > s) return null;
    const o = Math.sqrt(s - r), a = n - o, l = n + o;
    return l < 0 ? null : a < 0 ? this.at(l, t) : this.at(a, t);
  }
  intersectsSphere(e) {
    return this.distanceSqToPoint(e.center) <= e.radius * e.radius;
  }
  distanceToPlane(e) {
    const t = e.normal.dot(this.direction);
    if (t === 0)
      return e.distanceToPoint(this.origin) === 0 ? 0 : null;
    const n = -(this.origin.dot(e.normal) + e.constant) / t;
    return n >= 0 ? n : null;
  }
  intersectPlane(e, t) {
    const n = this.distanceToPlane(e);
    return n === null ? null : this.at(n, t);
  }
  intersectsPlane(e) {
    const t = e.distanceToPoint(this.origin);
    return t === 0 || e.normal.dot(this.direction) * t < 0;
  }
  intersectBox(e, t) {
    let n, r, s, o, a, l;
    const c = 1 / this.direction.x, h = 1 / this.direction.y, d = 1 / this.direction.z, p = this.origin;
    return c >= 0 ? (n = (e.min.x - p.x) * c, r = (e.max.x - p.x) * c) : (n = (e.max.x - p.x) * c, r = (e.min.x - p.x) * c), h >= 0 ? (s = (e.min.y - p.y) * h, o = (e.max.y - p.y) * h) : (s = (e.max.y - p.y) * h, o = (e.min.y - p.y) * h), n > o || s > r || ((s > n || isNaN(n)) && (n = s), (o < r || isNaN(r)) && (r = o), d >= 0 ? (a = (e.min.z - p.z) * d, l = (e.max.z - p.z) * d) : (a = (e.max.z - p.z) * d, l = (e.min.z - p.z) * d), n > l || a > r) || ((a > n || n !== n) && (n = a), (l < r || r !== r) && (r = l), r < 0) ? null : this.at(n >= 0 ? n : r, t);
  }
  intersectsBox(e) {
    return this.intersectBox(e, Wt) !== null;
  }
  intersectTriangle(e, t, n, r, s) {
    Rr.subVectors(t, e), Ci.subVectors(n, e), Cr.crossVectors(Rr, Ci);
    let o = this.direction.dot(Cr), a;
    if (o > 0) {
      if (r) return null;
      a = 1;
    } else if (o < 0)
      a = -1, o = -o;
    else
      return null;
    en.subVectors(this.origin, e);
    const l = a * this.direction.dot(Ci.crossVectors(en, Ci));
    if (l < 0)
      return null;
    const c = a * this.direction.dot(Rr.cross(en));
    if (c < 0 || l + c > o)
      return null;
    const h = -a * en.dot(Cr);
    return h < 0 ? null : this.at(h / o, s);
  }
  applyMatrix4(e) {
    return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;
  }
  equals(e) {
    return e.origin.equals(this.origin) && e.direction.equals(this.direction);
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Qe {
  constructor(e, t, n, r, s, o, a, l, c, h, d, p, m, g, v, f) {
    Qe.prototype.isMatrix4 = !0, this.elements = [
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1,
      0,
      0,
      0,
      0,
      1
    ], e !== void 0 && this.set(e, t, n, r, s, o, a, l, c, h, d, p, m, g, v, f);
  }
  set(e, t, n, r, s, o, a, l, c, h, d, p, m, g, v, f) {
    const u = this.elements;
    return u[0] = e, u[4] = t, u[8] = n, u[12] = r, u[1] = s, u[5] = o, u[9] = a, u[13] = l, u[2] = c, u[6] = h, u[10] = d, u[14] = p, u[3] = m, u[7] = g, u[11] = v, u[15] = f, 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 Qe().fromArray(this.elements);
  }
  copy(e) {
    const t = this.elements, n = e.elements;
    return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], 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) {
    const t = this.elements, n = e.elements;
    return t[12] = n[12], t[13] = n[13], t[14] = n[14], this;
  }
  setFromMatrix3(e) {
    const t = e.elements;
    return this.set(
      t[0],
      t[3],
      t[6],
      0,
      t[1],
      t[4],
      t[7],
      0,
      t[2],
      t[5],
      t[8],
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractBasis(e, t, n) {
    return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this;
  }
  makeBasis(e, t, n) {
    return this.set(
      e.x,
      t.x,
      n.x,
      0,
      e.y,
      t.y,
      n.y,
      0,
      e.z,
      t.z,
      n.z,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  extractRotation(e) {
    const t = this.elements, n = e.elements, r = 1 / On.setFromMatrixColumn(e, 0).length(), s = 1 / On.setFromMatrixColumn(e, 1).length(), o = 1 / On.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] * s, t[5] = n[5] * s, t[6] = n[6] * s, t[7] = 0, t[8] = n[8] * o, t[9] = n[9] * o, t[10] = n[10] * o, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
  }
  makeRotationFromEuler(e) {
    const t = this.elements, n = e.x, r = e.y, s = e.z, o = Math.cos(n), a = Math.sin(n), l = Math.cos(r), c = Math.sin(r), h = Math.cos(s), d = Math.sin(s);
    if (e.order === "XYZ") {
      const p = o * h, m = o * d, g = a * h, v = a * d;
      t[0] = l * h, t[4] = -l * d, t[8] = c, t[1] = m + g * c, t[5] = p - v * c, t[9] = -a * l, t[2] = v - p * c, t[6] = g + m * c, t[10] = o * l;
    } else if (e.order === "YXZ") {
      const p = l * h, m = l * d, g = c * h, v = c * d;
      t[0] = p + v * a, t[4] = g * a - m, t[8] = o * c, t[1] = o * d, t[5] = o * h, t[9] = -a, t[2] = m * a - g, t[6] = v + p * a, t[10] = o * l;
    } else if (e.order === "ZXY") {
      const p = l * h, m = l * d, g = c * h, v = c * d;
      t[0] = p - v * a, t[4] = -o * d, t[8] = g + m * a, t[1] = m + g * a, t[5] = o * h, t[9] = v - p * a, t[2] = -o * c, t[6] = a, t[10] = o * l;
    } else if (e.order === "ZYX") {
      const p = o * h, m = o * d, g = a * h, v = a * d;
      t[0] = l * h, t[4] = g * c - m, t[8] = p * c + v, t[1] = l * d, t[5] = v * c + p, t[9] = m * c - g, t[2] = -c, t[6] = a * l, t[10] = o * l;
    } else if (e.order === "YZX") {
      const p = o * l, m = o * c, g = a * l, v = a * c;
      t[0] = l * h, t[4] = v - p * d, t[8] = g * d + m, t[1] = d, t[5] = o * h, t[9] = -a * h, t[2] = -c * h, t[6] = m * d + g, t[10] = p - v * d;
    } else if (e.order === "XZY") {
      const p = o * l, m = o * c, g = a * l, v = a * c;
      t[0] = l * h, t[4] = -d, t[8] = c * h, t[1] = p * d + v, t[5] = o * h, t[9] = m * d - g, t[2] = g * d - m, t[6] = a * h, t[10] = v * d + p;
    }
    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(ec, e, tc);
  }
  lookAt(e, t, n) {
    const r = this.elements;
    return Et.subVectors(e, t), Et.lengthSq() === 0 && (Et.z = 1), Et.normalize(), tn.crossVectors(n, Et), tn.lengthSq() === 0 && (Math.abs(n.z) === 1 ? Et.x += 1e-4 : Et.z += 1e-4, Et.normalize(), tn.crossVectors(n, Et)), tn.normalize(), Li.crossVectors(Et, tn), r[0] = tn.x, r[4] = Li.x, r[8] = Et.x, r[1] = tn.y, r[5] = Li.y, r[9] = Et.y, r[2] = tn.z, r[6] = Li.z, r[10] = Et.z, this;
  }
  multiply(e) {
    return this.multiplyMatrices(this, e);
  }
  premultiply(e) {
    return this.multiplyMatrices(e, this);
  }
  multiplyMatrices(e, t) {
    const n = e.elements, r = t.elements, s = this.elements, o = n[0], a = n[4], l = n[8], c = n[12], h = n[1], d = n[5], p = n[9], m = n[13], g = n[2], v = n[6], f = n[10], u = n[14], b = n[3], S = n[7], R = n[11], D = n[15], C = r[0], A = r[4], W = r[8], x = r[12], y = r[1], z = r[5], Z = r[9], re = r[13], L = r[2], F = r[6], V = r[10], Y = r[14], X = r[3], k = r[7], q = r[11], Q = r[15];
    return s[0] = o * C + a * y + l * L + c * X, s[4] = o * A + a * z + l * F + c * k, s[8] = o * W + a * Z + l * V + c * q, s[12] = o * x + a * re + l * Y + c * Q, s[1] = h * C + d * y + p * L + m * X, s[5] = h * A + d * z + p * F + m * k, s[9] = h * W + d * Z + p * V + m * q, s[13] = h * x + d * re + p * Y + m * Q, s[2] = g * C + v * y + f * L + u * X, s[6] = g * A + v * z + f * F + u * k, s[10] = g * W + v * Z + f * V + u * q, s[14] = g * x + v * re + f * Y + u * Q, s[3] = b * C + S * y + R * L + D * X, s[7] = b * A + S * z + R * F + D * k, s[11] = b * W + S * Z + R * V + D * q, s[15] = b * x + S * re + R * Y + D * Q, this;
  }
  multiplyScalar(e) {
    const 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() {
    const e = this.elements, t = e[0], n = e[4], r = e[8], s = e[12], o = e[1], a = e[5], l = e[9], c = e[13], h = e[2], d = e[6], p = e[10], m = e[14], g = e[3], v = e[7], f = e[11], u = e[15];
    return g * (+s * l * d - r * c * d - s * a * p + n * c * p + r * a * m - n * l * m) + v * (+t * l * m - t * c * p + s * o * p - r * o * m + r * c * h - s * l * h) + f * (+t * c * d - t * a * m - s * o * d + n * o * m + s * a * h - n * c * h) + u * (-r * a * h - t * l * d + t * a * p + r * o * d - n * o * p + n * l * h);
  }
  transpose() {
    const e = this.elements;
    let 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) {
    const 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() {
    const e = this.elements, t = e[0], n = e[1], r = e[2], s = e[3], o = e[4], a = e[5], l = e[6], c = e[7], h = e[8], d = e[9], p = e[10], m = e[11], g = e[12], v = e[13], f = e[14], u = e[15], b = d * f * c - v * p * c + v * l * m - a * f * m - d * l * u + a * p * u, S = g * p * c - h * f * c - g * l * m + o * f * m + h * l * u - o * p * u, R = h * v * c - g * d * c + g * a * m - o * v * m - h * a * u + o * d * u, D = g * d * l - h * v * l - g * a * p + o * v * p + h * a * f - o * d * f, C = t * b + n * S + r * R + s * D;
    if (C === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    const A = 1 / C;
    return e[0] = b * A, e[1] = (v * p * s - d * f * s - v * r * m + n * f * m + d * r * u - n * p * u) * A, e[2] = (a * f * s - v * l * s + v * r * c - n * f * c - a * r * u + n * l * u) * A, e[3] = (d * l * s - a * p * s - d * r * c + n * p * c + a * r * m - n * l * m) * A, e[4] = S * A, e[5] = (h * f * s - g * p * s + g * r * m - t * f * m - h * r * u + t * p * u) * A, e[6] = (g * l * s - o * f * s - g * r * c + t * f * c + o * r * u - t * l * u) * A, e[7] = (o * p * s - h * l * s + h * r * c - t * p * c - o * r * m + t * l * m) * A, e[8] = R * A, e[9] = (g * d * s - h * v * s - g * n * m + t * v * m + h * n * u - t * d * u) * A, e[10] = (o * v * s - g * a * s + g * n * c - t * v * c - o * n * u + t * a * u) * A, e[11] = (h * a * s - o * d * s - h * n * c + t * d * c + o * n * m - t * a * m) * A, e[12] = D * A, e[13] = (h * v * r - g * d * r + g * n * p - t * v * p - h * n * f + t * d * f) * A, e[14] = (g * a * r - o * v * r - g * n * l + t * v * l + o * n * f - t * a * f) * A, e[15] = (o * d * r - h * a * r + h * n * l - t * d * l - o * n * p + t * a * p) * A, this;
  }
  scale(e) {
    const t = this.elements, n = e.x, r = e.y, s = e.z;
    return t[0] *= n, t[4] *= r, t[8] *= s, t[1] *= n, t[5] *= r, t[9] *= s, t[2] *= n, t[6] *= r, t[10] *= s, t[3] *= n, t[7] *= r, t[11] *= s, this;
  }
  getMaxScaleOnAxis() {
    const 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) {
    const 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) {
    const 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) {
    const 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) {
    const n = Math.cos(t), r = Math.sin(t), s = 1 - n, o = e.x, a = e.y, l = e.z, c = s * o, h = s * a;
    return this.set(
      c * o + n,
      c * a - r * l,
      c * l + r * a,
      0,
      c * a + r * l,
      h * a + n,
      h * l - r * o,
      0,
      c * l - r * a,
      h * l + r * o,
      s * l * l + 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, s, o) {
    return this.set(
      1,
      n,
      s,
      0,
      e,
      1,
      o,
      0,
      t,
      r,
      1,
      0,
      0,
      0,
      0,
      1
    ), this;
  }
  compose(e, t, n) {
    const r = this.elements, s = t._x, o = t._y, a = t._z, l = t._w, c = s + s, h = o + o, d = a + a, p = s * c, m = s * h, g = s * d, v = o * h, f = o * d, u = a * d, b = l * c, S = l * h, R = l * d, D = n.x, C = n.y, A = n.z;
    return r[0] = (1 - (v + u)) * D, r[1] = (m + R) * D, r[2] = (g - S) * D, r[3] = 0, r[4] = (m - R) * C, r[5] = (1 - (p + u)) * C, r[6] = (f + b) * C, r[7] = 0, r[8] = (g + S) * A, r[9] = (f - b) * A, r[10] = (1 - (p + v)) * A, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this;
  }
  decompose(e, t, n) {
    const r = this.elements;
    let s = On.set(r[0], r[1], r[2]).length();
    const o = On.set(r[4], r[5], r[6]).length(), a = On.set(r[8], r[9], r[10]).length();
    this.determinant() < 0 && (s = -s), e.x = r[12], e.y = r[13], e.z = r[14], Pt.copy(this);
    const c = 1 / s, h = 1 / o, d = 1 / a;
    return Pt.elements[0] *= c, Pt.elements[1] *= c, Pt.elements[2] *= c, Pt.elements[4] *= h, Pt.elements[5] *= h, Pt.elements[6] *= h, Pt.elements[8] *= d, Pt.elements[9] *= d, Pt.elements[10] *= d, t.setFromRotationMatrix(Pt), n.x = s, n.y = o, n.z = a, this;
  }
  makePerspective(e, t, n, r, s, o, a = Zt) {
    const l = this.elements, c = 2 * s / (t - e), h = 2 * s / (n - r), d = (t + e) / (t - e), p = (n + r) / (n - r);
    let m, g;
    if (a === Zt)
      m = -(o + s) / (o - s), g = -2 * o * s / (o - s);
    else if (a === tr)
      m = -o / (o - s), g = -o * s / (o - s);
    else
      throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + a);
    return l[0] = c, l[4] = 0, l[8] = d, l[12] = 0, l[1] = 0, l[5] = h, l[9] = p, l[13] = 0, l[2] = 0, l[6] = 0, l[10] = m, l[14] = g, l[3] = 0, l[7] = 0, l[11] = -1, l[15] = 0, this;
  }
  makeOrthographic(e, t, n, r, s, o, a = Zt) {
    const l = this.elements, c = 1 / (t - e), h = 1 / (n - r), d = 1 / (o - s), p = (t + e) * c, m = (n + r) * h;
    let g, v;
    if (a === Zt)
      g = (o + s) * d, v = -2 * d;
    else if (a === tr)
      g = s * d, v = -1 * d;
    else
      throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + a);
    return l[0] = 2 * c, l[4] = 0, l[8] = 0, l[12] = -p, l[1] = 0, l[5] = 2 * h, l[9] = 0, l[13] = -m, l[2] = 0, l[6] = 0, l[10] = v, l[14] = -g, l[3] = 0, l[7] = 0, l[11] = 0, l[15] = 1, this;
  }
  equals(e) {
    const t = this.elements, n = e.elements;
    for (let r = 0; r < 16; r++)
      if (t[r] !== n[r]) 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) {
    const n = this.elements;
    return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[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;
  }
}
const On = /* @__PURE__ */ new P(), Pt = /* @__PURE__ */ new Qe(), ec = /* @__PURE__ */ new P(0, 0, 0), tc = /* @__PURE__ */ new P(1, 1, 1), tn = /* @__PURE__ */ new P(), Li = /* @__PURE__ */ new P(), Et = /* @__PURE__ */ new P(), oa = /* @__PURE__ */ new Qe(), la = /* @__PURE__ */ new An();
class ar {
  constructor(e = 0, t = 0, n = 0, r = ar.DEFAULT_ORDER) {
    this.isEuler = !0, this._x = e, this._y = t, this._z = n, this._order = r;
  }
  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) {
    const r = e.elements, s = r[0], o = r[4], a = r[8], l = r[1], c = r[5], h = r[9], d = r[2], p = r[6], m = r[10];
    switch (t) {
      case "XYZ":
        this._y = Math.asin(vt(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(-h, m), this._z = Math.atan2(-o, s)) : (this._x = Math.atan2(p, c), this._z = 0);
        break;
      case "YXZ":
        this._x = Math.asin(-vt(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(a, m), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-d, s), this._z = 0);
        break;
      case "ZXY":
        this._x = Math.asin(vt(p, -1, 1)), Math.abs(p) < 0.9999999 ? (this._y = Math.atan2(-d, m), this._z = Math.atan2(-o, c)) : (this._y = 0, this._z = Math.atan2(l, s));
        break;
      case "ZYX":
        this._y = Math.asin(-vt(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._x = Math.atan2(p, m), this._z = Math.atan2(l, s)) : (this._x = 0, this._z = Math.atan2(-o, c));
        break;
      case "YZX":
        this._z = Math.asin(vt(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-d, s)) : (this._x = 0, this._y = Math.atan2(a, m));
        break;
      case "XZY":
        this._z = Math.asin(-vt(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(p, c), this._y = Math.atan2(a, s)) : (this._x = Math.atan2(-h, m), this._y = 0);
        break;
      default:
        console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: " + t);
    }
    return this._order = t, n === !0 && this._onChangeCallback(), this;
  }
  setFromQuaternion(e, t, n) {
    return oa.makeRotationFromQuaternion(e), this.setFromRotationMatrix(oa, t, n);
  }
  setFromVector3(e, t = this._order) {
    return this.set(e.x, e.y, e.z, t);
  }
  reorder(e) {
    return la.setFromEuler(this), this.setFromQuaternion(la, 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;
  }
}
ar.DEFAULT_ORDER = "XYZ";
class bo {
  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;
  }
}
let nc = 0;
const ca = /* @__PURE__ */ new P(), Bn = /* @__PURE__ */ new An(), Xt = /* @__PURE__ */ new Qe(), Pi = /* @__PURE__ */ new P(), ui = /* @__PURE__ */ new P(), ic = /* @__PURE__ */ new P(), rc = /* @__PURE__ */ new An(), ua = /* @__PURE__ */ new P(1, 0, 0), ha = /* @__PURE__ */ new P(0, 1, 0), da = /* @__PURE__ */ new P(0, 0, 1), sc = { type: "added" }, ac = { type: "removed" };
class dt extends Rn {
  constructor() {
    super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: nc++ }), this.uuid = vi(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = dt.DEFAULT_UP.clone();
    const e = new P(), t = new ar(), n = new An(), r = new P(1, 1, 1);
    function s() {
      n.setFromEuler(t, !1);
    }
    function o() {
      t.setFromQuaternion(n, void 0, !1);
    }
    t._onChange(s), n._onChange(o), Object.defineProperties(this, {
      position: {
        configurable: !0,
        enumerable: !0,
        value: e
      },
      rotation: {
        configurable: !0,
        enumerable: !0,
        value: t
      },
      quaternion: {
        configurable: !0,
        enumerable: !0,
        value: n
      },
      scale: {
        configurable: !0,
        enumerable: !0,
        value: r
      },
      modelViewMatrix: {
        value: new Qe()
      },
      normalMatrix: {
        value: new Ve()
      }
    }), this.matrix = new Qe(), this.matrixWorld = new Qe(), this.matrixAutoUpdate = dt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new bo(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.userData = {};
  }
  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 Bn.setFromAxisAngle(e, t), this.quaternion.multiply(Bn), this;
  }
  rotateOnWorldAxis(e, t) {
    return Bn.setFromAxisAngle(e, t), this.quaternion.premultiply(Bn), this;
  }
  rotateX(e) {
    return this.rotateOnAxis(ua, e);
  }
  rotateY(e) {
    return this.rotateOnAxis(ha, e);
  }
  rotateZ(e) {
    return this.rotateOnAxis(da, e);
  }
  translateOnAxis(e, t) {
    return ca.copy(e).applyQuaternion(this.quaternion), this.position.add(ca.multiplyScalar(t)), this;
  }
  translateX(e) {
    return this.translateOnAxis(ua, e);
  }
  translateY(e) {
    return this.translateOnAxis(ha, e);
  }
  translateZ(e) {
    return this.translateOnAxis(da, e);
  }
  localToWorld(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
  }
  worldToLocal(e) {
    return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Xt.copy(this.matrixWorld).invert());
  }
  lookAt(e, t, n) {
    e.isVector3 ? Pi.copy(e) : Pi.set(e, t, n);
    const r = this.parent;
    this.updateWorldMatrix(!0, !1), ui.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Xt.lookAt(ui, Pi, this.up) : Xt.lookAt(Pi, ui, this.up), this.quaternion.setFromRotationMatrix(Xt), r && (Xt.extractRotation(r.matrixWorld), Bn.setFromRotationMatrix(Xt), this.quaternion.premultiply(Bn.invert()));
  }
  add(e) {
    if (arguments.length > 1) {
      for (let t = 0; t < arguments.length; t++)
        this.add(arguments[t]);
      return this;
    }
    return e === this ? (console.error("THREE.Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.parent !== null && e.parent.remove(e), e.parent = this, this.children.push(e), e.dispatchEvent(sc)) : console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.", e), this);
  }
  remove(e) {
    if (arguments.length > 1) {
      for (let n = 0; n < arguments.length; n++)
        this.remove(arguments[n]);
      return this;
    }
    const t = this.children.indexOf(e);
    return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(ac)), this;
  }
  removeFromParent() {
    const e = this.parent;
    return e !== null && e.remove(this), this;
  }
  clear() {
    return this.remove(...this.children);
  }
  attach(e) {
    return this.updateWorldMatrix(!0, !1), Xt.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Xt.multiply(e.parent.matrixWorld)), e.applyMatrix4(Xt), this.add(e), e.updateWorldMatrix(!1, !0), 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++) {
      const o = this.children[n].getObjectByProperty(e, t);
      if (o !== void 0)
        return o;
    }
  }
  getObjectsByProperty(e, t, n = []) {
    this[e] === t && n.push(this);
    const r = this.children;
    for (let s = 0, o = r.length; s < o; s++)
      r[s].getObjectsByProperty(e, t, n);
    return n;
  }
  getWorldPosition(e) {
    return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);
  }
  getWorldQuaternion(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(ui, e, ic), e;
  }
  getWorldScale(e) {
    return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(ui, rc, e), e;
  }
  getWorldDirection(e) {
    this.updateWorldMatrix(!0, !1);
    const t = this.matrixWorld.elements;
    return e.set(t[8], t[9], t[10]).normalize();
  }
  raycast() {
  }
  traverse(e) {
    e(this);
    const 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);
    const t = this.children;
    for (let n = 0, r = t.length; n < r; n++)
      t[n].traverseVisible(e);
  }
  traverseAncestors(e) {
    const t = this.parent;
    t !== null && (e(t), t.traverseAncestors(e));
  }
  updateMatrix() {
    this.matrix.compose(this.position, this.quaternion, this.scale), this.matrixWorldNeedsUpdate = !0;
  }
  updateMatrixWorld(e) {
    this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), this.matrixWorldNeedsUpdate = !1, e = !0);
    const t = this.children;
    for (let n = 0, r = t.length; n < r; n++) {
      const s = t[n];
      (s.matrixWorldAutoUpdate === !0 || e === !0) && s.updateMatrixWorld(e);
    }
  }
  updateWorldMatrix(e, t) {
    const n = this.parent;
    if (e === !0 && n !== null && n.matrixWorldAutoUpdate === !0 && n.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix), t === !0) {
      const r = this.children;
      for (let s = 0, o = r.length; s < o; s++) {
        const a = r[s];
        a.matrixWorldAutoUpdate === !0 && a.updateWorldMatrix(!1, !0);
      }
    }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string", n = {};
    t && (e = {
      geometries: {},
      materials: {},
      textures: {},
      images: {},
      shapes: {},
      skeletons: {},
      animations: {},
      nodes: {}
    }, n.metadata = {
      version: 4.6,
      type: "Object",
      generator: "Object3D.toJSON"
    });
    const 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), 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.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), 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.visibility = this._visibility, r.active = this._active, r.bounds = this._bounds.map((a) => ({
      boxInitialized: a.boxInitialized,
      boxMin: a.box.min.toArray(),
      boxMax: a.box.max.toArray(),
      sphereInitialized: a.sphereInitialized,
      sphereRadius: a.sphere.radius,
      sphereCenter: a.sphere.center.toArray()
    })), r.maxGeometryCount = this._maxGeometryCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.geometryCount = this._geometryCount, r.matricesTexture = this._matricesTexture.toJSON(e), this.boundingSphere !== null && (r.boundingSphere = {
      center: r.boundingSphere.center.toArray(),
      radius: r.boundingSphere.radius
    }), this.boundingBox !== null && (r.boundingBox = {
      min: r.boundingBox.min.toArray(),
      max: r.boundingBox.max.toArray()
    }));
    function s(a, l) {
      return a[l.uuid] === void 0 && (a[l.uuid] = l.toJSON(e)), l.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 = s(e.geometries, this.geometry);
      const a = this.geometry.parameters;
      if (a !== void 0 && a.shapes !== void 0) {
        const l = a.shapes;
        if (Array.isArray(l))
          for (let c = 0, h = l.length; c < h; c++) {
            const d = l[c];
            s(e.shapes, d);
          }
        else
          s(e.shapes, l);
      }
    }
    if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (s(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0)
      if (Array.isArray(this.material)) {
        const a = [];
        for (let l = 0, c = this.material.length; l < c; l++)
          a.push(s(e.materials, this.material[l]));
        r.material = a;
      } else
        r.material = s(e.materials, this.material);
    if (this.children.length > 0) {
      r.children = [];
      for (let a = 0; a < this.children.length; a++)
        r.children.push(this.children[a].toJSON(e).object);
    }
    if (this.animations.length > 0) {
      r.animations = [];
      for (let a = 0; a < this.animations.length; a++) {
        const l = this.animations[a];
        r.animations.push(s(e.animations, l));
      }
    }
    if (t) {
      const a = o(e.geometries), l = o(e.materials), c = o(e.textures), h = o(e.images), d = o(e.shapes), p = o(e.skeletons), m = o(e.animations), g = o(e.nodes);
      a.length > 0 && (n.geometries = a), l.length > 0 && (n.materials = l), c.length > 0 && (n.textures = c), h.length > 0 && (n.images = h), d.length > 0 && (n.shapes = d), p.length > 0 && (n.skeletons = p), m.length > 0 && (n.animations = m), g.length > 0 && (n.nodes = g);
    }
    return n.object = r, n;
    function o(a) {
      const l = [];
      for (const c in a) {
        const h = a[c];
        delete h.metadata, l.push(h);
      }
      return l;
    }
  }
  clone(e) {
    return new this.constructor().copy(this, e);
  }
  copy(e, t = !0) {
    if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0)
      for (let n = 0; n < e.children.length; n++) {
        const r = e.children[n];
        this.add(r.clone());
      }
    return this;
  }
}
dt.DEFAULT_UP = /* @__PURE__ */ new P(0, 1, 0);
dt.DEFAULT_MATRIX_AUTO_UPDATE = !0;
dt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0;
const Dt = /* @__PURE__ */ new P(), qt = /* @__PURE__ */ new P(), Lr = /* @__PURE__ */ new P(), Yt = /* @__PURE__ */ new P(), zn = /* @__PURE__ */ new P(), Gn = /* @__PURE__ */ new P(), fa = /* @__PURE__ */ new P(), Pr = /* @__PURE__ */ new P(), Dr = /* @__PURE__ */ new P(), Ur = /* @__PURE__ */ new P();
let Di = !1;
class It {
  constructor(e = new P(), t = new P(), n = new P()) {
    this.a = e, this.b = t, this.c = n;
  }
  static getNormal(e, t, n, r) {
    r.subVectors(n, t), Dt.subVectors(e, t), r.cross(Dt);
    const s = r.lengthSq();
    return s > 0 ? r.multiplyScalar(1 / Math.sqrt(s)) : r.set(0, 0, 0);
  }
  // static/instance method to calculate barycentric coordinates
  // based on: http://www.blackpawn.com/texts/pointinpoly/default.html
  static getBarycoord(e, t, n, r, s) {
    Dt.subVectors(r, t), qt.subVectors(n, t), Lr.subVectors(e, t);
    const o = Dt.dot(Dt), a = Dt.dot(qt), l = Dt.dot(Lr), c = qt.dot(qt), h = qt.dot(Lr), d = o * c - a * a;
    if (d === 0)
      return s.set(0, 0, 0), null;
    const p = 1 / d, m = (c * l - a * h) * p, g = (o * h - a * l) * p;
    return s.set(1 - m - g, g, m);
  }
  static containsPoint(e, t, n, r) {
    return this.getBarycoord(e, t, n, r, Yt) === null ? !1 : Yt.x >= 0 && Yt.y >= 0 && Yt.x + Yt.y <= 1;
  }
  static getUV(e, t, n, r, s, o, a, l) {
    return Di === !1 && (console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."), Di = !0), this.getInterpolation(e, t, n, r, s, o, a, l);
  }
  static getInterpolation(e, t, n, r, s, o, a, l) {
    return this.getBarycoord(e, t, n, r, Yt) === null ? (l.x = 0, l.y = 0, "z" in l && (l.z = 0), "w" in l && (l.w = 0), null) : (l.setScalar(0), l.addScaledVector(s, Yt.x), l.addScaledVector(o, Yt.y), l.addScaledVector(a, Yt.z), l);
  }
  static isFrontFacing(e, t, n, r) {
    return Dt.subVectors(n, t), qt.subVectors(e, t), Dt.cross(qt).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 Dt.subVectors(this.c, this.b), qt.subVectors(this.a, this.b), Dt.cross(qt).length() * 0.5;
  }
  getMidpoint(e) {
    return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);
  }
  getNormal(e) {
    return It.getNormal(this.a, this.b, this.c, e);
  }
  getPlane(e) {
    return e.setFromCoplanarPoints(this.a, this.b, this.c);
  }
  getBarycoord(e, t) {
    return It.getBarycoord(e, this.a, this.b, this.c, t);
  }
  getUV(e, t, n, r, s) {
    return Di === !1 && (console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."), Di = !0), It.getInterpolation(e, this.a, this.b, this.c, t, n, r, s);
  }
  getInterpolation(e, t, n, r, s) {
    return It.getInterpolation(e, this.a, this.b, this.c, t, n, r, s);
  }
  containsPoint(e) {
    return It.containsPoint(e, this.a, this.b, this.c);
  }
  isFrontFacing(e) {
    return It.isFrontFacing(this.a, this.b, this.c, e);
  }
  intersectsBox(e) {
    return e.intersectsTriangle(this);
  }
  closestPointToPoint(e, t) {
    const n = this.a, r = this.b, s = this.c;
    let o, a;
    zn.subVectors(r, n), Gn.subVectors(s, n), Pr.subVectors(e, n);
    const l = zn.dot(Pr), c = Gn.dot(Pr);
    if (l <= 0 && c <= 0)
      return t.copy(n);
    Dr.subVectors(e, r);
    const h = zn.dot(Dr), d = Gn.dot(Dr);
    if (h >= 0 && d <= h)
      return t.copy(r);
    const p = l * d - h * c;
    if (p <= 0 && l >= 0 && h <= 0)
      return o = l / (l - h), t.copy(n).addScaledVector(zn, o);
    Ur.subVectors(e, s);
    const m = zn.dot(Ur), g = Gn.dot(Ur);
    if (g >= 0 && m <= g)
      return t.copy(s);
    const v = m * c - l * g;
    if (v <= 0 && c >= 0 && g <= 0)
      return a = c / (c - g), t.copy(n).addScaledVector(Gn, a);
    const f = h * g - m * d;
    if (f <= 0 && d - h >= 0 && m - g >= 0)
      return fa.subVectors(s, r), a = (d - h) / (d - h + (m - g)), t.copy(r).addScaledVector(fa, a);
    const u = 1 / (f + v + p);
    return o = v * u, a = p * u, t.copy(n).addScaledVector(zn, o).addScaledVector(Gn, a);
  }
  equals(e) {
    return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c);
  }
}
const Ao = {
  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
}, nn = { h: 0, s: 0, l: 0 }, Ui = { h: 0, s: 0, l: 0 };
function Ir(i, e, t) {
  return t < 0 && (t += 1), t > 1 && (t -= 1), t < 1 / 6 ? i + (e - i) * 6 * t : t < 1 / 2 ? e : t < 2 / 3 ? i + (e - i) * 6 * (2 / 3 - t) : i;
}
class Xe {
  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) {
      const r = e;
      r && r.isColor ? this.copy(r) : typeof r == "number" ? this.setHex(r) : typeof r == "string" && this.setStyle(r);
    } else
      this.setRGB(e, t, n);
    return this;
  }
  setScalar(e) {
    return this.r = e, this.g = e, this.b = e, this;
  }
  setHex(e, t = ht) {
    return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, Ke.toWorkingColorSpace(this, t), this;
  }
  setRGB(e, t, n, r = Ke.workingColorSpace) {
    return this.r = e, this.g = t, this.b = n, Ke.toWorkingColorSpace(this, r), this;
  }
  setHSL(e, t, n, r = Ke.workingColorSpace) {
    if (e = Xl(e, 1), t = vt(t, 0, 1), n = vt(n, 0, 1), t === 0)
      this.r = this.g = this.b = n;
    else {
      const s = n <= 0.5 ? n * (1 + t) : n + t - n * t, o = 2 * n - s;
      this.r = Ir(o, s, e + 1 / 3), this.g = Ir(o, s, e), this.b = Ir(o, s, e - 1 / 3);
    }
    return Ke.toWorkingColorSpace(this, r), this;
  }
  setStyle(e, t = ht) {
    function n(s) {
      s !== void 0 && parseFloat(s) < 1 && console.warn("THREE.Color: Alpha component of " + e + " will be ignored.");
    }
    let r;
    if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) {
      let s;
      const o = r[1], a = r[2];
      switch (o) {
        case "rgb":
        case "rgba":
          if (s = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
            return n(s[4]), this.setRGB(
              Math.min(255, parseInt(s[1], 10)) / 255,
              Math.min(255, parseInt(s[2], 10)) / 255,
              Math.min(255, parseInt(s[3], 10)) / 255,
              t
            );
          if (s = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
            return n(s[4]), this.setRGB(
              Math.min(100, parseInt(s[1], 10)) / 100,
              Math.min(100, parseInt(s[2], 10)) / 100,
              Math.min(100, parseInt(s[3], 10)) / 100,
              t
            );
          break;
        case "hsl":
        case "hsla":
          if (s = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))
            return n(s[4]), this.setHSL(
              parseFloat(s[1]) / 360,
              parseFloat(s[2]) / 100,
              parseFloat(s[3]) / 100,
              t
            );
          break;
        default:
          console.warn("THREE.Color: Unknown color model " + e);
      }
    } else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) {
      const s = r[1], o = s.length;
      if (o === 3)
        return this.setRGB(
          parseInt(s.charAt(0), 16) / 15,
          parseInt(s.charAt(1), 16) / 15,
          parseInt(s.charAt(2), 16) / 15,
          t
        );
      if (o === 6)
        return this.setHex(parseInt(s, 16), t);
      console.warn("THREE.Color: Invalid hex color " + e);
    } else if (e && e.length > 0)
      return this.setColorName(e, t);
    return this;
  }
  setColorName(e, t = ht) {
    const n = Ao[e.toLowerCase()];
    return n !== void 0 ? this.setHex(n, t) : console.warn("THREE.Color: Unknown color " + e), 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 = Jn(e.r), this.g = Jn(e.g), this.b = Jn(e.b), this;
  }
  copyLinearToSRGB(e) {
    return this.r = Er(e.r), this.g = Er(e.g), this.b = Er(e.b), this;
  }
  convertSRGBToLinear() {
    return this.copySRGBToLinear(this), this;
  }
  convertLinearToSRGB() {
    return this.copyLinearToSRGB(this), this;
  }
  getHex(e = ht) {
    return Ke.fromWorkingColorSpace(mt.copy(this), e), Math.round(vt(mt.r * 255, 0, 255)) * 65536 + Math.round(vt(mt.g * 255, 0, 255)) * 256 + Math.round(vt(mt.b * 255, 0, 255));
  }
  getHexString(e = ht) {
    return ("000000" + this.getHex(e).toString(16)).slice(-6);
  }
  getHSL(e, t = Ke.workingColorSpace) {
    Ke.fromWorkingColorSpace(mt.copy(this), t);
    const n = mt.r, r = mt.g, s = mt.b, o = Math.max(n, r, s), a = Math.min(n, r, s);
    let l, c;
    const h = (a + o) / 2;
    if (a === o)
      l = 0, c = 0;
    else {
      const d = o - a;
      switch (c = h <= 0.5 ? d / (o + a) : d / (2 - o - a), o) {
        case n:
          l = (r - s) / d + (r < s ? 6 : 0);
          break;
        case r:
          l = (s - n) / d + 2;
          break;
        case s:
          l = (n - r) / d + 4;
          break;
      }
      l /= 6;
    }
    return e.h = l, e.s = c, e.l = h, e;
  }
  getRGB(e, t = Ke.workingColorSpace) {
    return Ke.fromWorkingColorSpace(mt.copy(this), t), e.r = mt.r, e.g = mt.g, e.b = mt.b, e;
  }
  getStyle(e = ht) {
    Ke.fromWorkingColorSpace(mt.copy(this), e);
    const t = mt.r, n = mt.g, r = mt.b;
    return e !== ht ? `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})` : `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(r * 255)})`;
  }
  offsetHSL(e, t, n) {
    return this.getHSL(nn), this.setHSL(nn.h + e, nn.s + t, nn.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(nn), e.getHSL(Ui);
    const n = Mr(nn.h, Ui.h, t), r = Mr(nn.s, Ui.s, t), s = Mr(nn.l, Ui.l, t);
    return this.setHSL(n, r, s), this;
  }
  setFromVector3(e) {
    return this.r = e.x, this.g = e.y, this.b = e.z, this;
  }
  applyMatrix3(e) {
    const t = this.r, n = this.g, r = this.b, s = e.elements;
    return this.r = s[0] * t + s[3] * n + s[6] * r, this.g = s[1] * t + s[4] * n + s[7] * r, this.b = s[2] * t + s[5] * n + s[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;
  }
}
const mt = /* @__PURE__ */ new Xe();
Xe.NAMES = Ao;
let oc = 0;
class Mi extends Rn {
  constructor() {
    super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: oc++ }), this.uuid = vi(), this.name = "", this.type = "Material", this.blending = $n, this.side = un, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = Kr, this.blendDst = Zr, this.blendEquation = Mn, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Xe(0, 0, 0), this.blendAlpha = 0, this.depthFunc = $i, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = Qs, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = Dn, this.stencilZFail = Dn, this.stencilZPass = Dn, 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.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;
  }
  onBuild() {
  }
  onBeforeRender() {
  }
  onBeforeCompile() {
  }
  customProgramCacheKey() {
    return this.onBeforeCompile.toString();
  }
  setValues(e) {
    if (e !== void 0)
      for (const t in e) {
        const n = e[t];
        if (n === void 0) {
          console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);
          continue;
        }
        const r = this[t];
        if (r === void 0) {
          console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);
          continue;
        }
        r && r.isColor ? r.set(n) : r && r.isVector3 && n && n.isVector3 ? r.copy(n) : this[t] = n;
      }
  }
  toJSON(e) {
    const t = e === void 0 || typeof e == "string";
    t && (e = {
      textures: {},
      images: {}
    });
    const n = {
      metadata: {
        version: 4.6,
        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 && 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.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.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 !== 1 / 0 && (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 !== $n && (n.blending = this.blending), this.side !== un && (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 !== Kr && (n.blendSrc = this.blendSrc), this.blendDst !== Zr && (n.blendDst = this.blendDst), this.blendEquation !== Mn && (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 !== $i && (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 !== Qs && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== Dn && (n.stencilFail = this.stencilFail), this.stencilZFail !== Dn && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== Dn && (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.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(s) {
      const o = [];
      for (const a in s) {
        const l = s[a];
        delete l.metadata, o.push(l);
      }
      return o;
    }
    if (t) {
      const s = r(e.textures), o = r(e.images);
      s.length > 0 && (n.textures = s), o.length > 0 && (n.images = o);
    }
    return n;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  copy(e) {
    this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite;
    const t = e.clippingPlanes;
    let n = null;
    if (t !== null) {
      const r = t.length;
      n = new Array(r);
      for (let s = 0; s !== r; ++s)
        n[s] = t[s].clone();
    }
    return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
}
class ls extends Mi {
  constructor(e) {
    super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new Xe(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.combine = oo, this.reflectivity = 1, this.refractionRatio = 0.98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.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;
  }
}
const at = /* @__PURE__ */ new P(), Ii = /* @__PURE__ */ new Ie();
class Bt {
  constructor(e, t, n = !1) {
    if (Array.isArray(e))
      throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");
    this.isBufferAttribute = !0, this.name = "", this.array = e, this.itemSize = t, this.count = e !== void 0 ? e.length / t : 0, this.normalized = n, this.usage = ea, this._updateRange = { offset: 0, count: -1 }, this.updateRanges = [], this.gpuType = an, this.version = 0;
  }
  onUploadCallback() {
  }
  set needsUpdate(e) {
    e === !0 && this.version++;
  }
  get updateRange() {
    return console.warn("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."), this._updateRange;
  }
  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, s = this.itemSize; r < s; 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++)
        Ii.fromBufferAttribute(this, t), Ii.applyMatrix3(e), this.setXY(t, Ii.x, Ii.y);
    else if (this.itemSize === 3)
      for (let t = 0, n = this.count; t < n; t++)
        at.fromBufferAttribute(this, t), at.applyMatrix3(e), this.setXYZ(t, at.x, at.y, at.z);
    return this;
  }
  applyMatrix4(e) {
    for (let t = 0, n = this.count; t < n; t++)
      at.fromBufferAttribute(this, t), at.applyMatrix4(e), this.setXYZ(t, at.x, at.y, at.z);
    return this;
  }
  applyNormalMatrix(e) {
    for (let t = 0, n = this.count; t < n; t++)
      at.fromBufferAttribute(this, t), at.applyNormalMatrix(e), this.setXYZ(t, at.x, at.y, at.z);
    return this;
  }
  transformDirection(e) {
    for (let t = 0, n = this.count; t < n; t++)
      at.fromBufferAttribute(this, t), at.transformDirection(e), this.setXYZ(t, at.x, at.y, at.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 = oi(n, this.array)), n;
  }
  setComponent(e, t, n) {
    return this.normalized && (n = xt(n, this.array)), this.array[e * this.itemSize + t] = n, this;
  }
  getX(e) {
    let t = this.array[e * this.itemSize];
    return this.normalized && (t = oi(t, this.array)), t;
  }
  setX(e, t) {
    return this.normalized && (t = xt(t, this.array)), this.array[e * this.itemSize] = t, this;
  }
  getY(e) {
    let t = this.array[e * this.itemSize + 1];
    return this.normalized && (t = oi(t, this.array)), t;
  }
  setY(e, t) {
    return this.normalized && (t = xt(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 = oi(t, this.array)), t;
  }
  setZ(e, t) {
    return this.normalized && (t = xt(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 = oi(t, this.array)), t;
  }
  setW(e, t) {
    return this.normalized && (t = xt(t, this.array)), this.array[e * this.itemSize + 3] = t, this;
  }
  setXY(e, t, n) {
    return e *= this.itemSize, this.normalized && (t = xt(t, this.array), n = xt(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 = xt(t, this.array), n = xt(n, this.array), r = xt(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this;
  }
  setXYZW(e, t, n, r, s) {
    return e *= this.itemSize, this.normalized && (t = xt(t, this.array), n = xt(n, this.array), r = xt(r, this.array), s = xt(s, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this.array[e + 3] = s, this;
  }
  onUpload(e) {
    return this.onUploadCallback = e, this;
  }
  clone() {
    return new this.constructor(this.array, this.itemSize).copy(this);
  }
  toJSON() {
    const 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 !== ea && (e.usage = this.usage), e;
  }
}
class wo extends Bt {
  constructor(e, t, n) {
    super(new Uint16Array(e), t, n);
  }
}
class Ro extends Bt {
  constructor(e, t, n) {
    super(new Uint32Array(e), t, n);
  }
}
class Ht extends Bt {
  constructor(e, t, n) {
    super(new Float32Array(e), t, n);
  }
}
let lc = 0;
const wt = /* @__PURE__ */ new Qe(), Nr = /* @__PURE__ */ new dt(), Hn = /* @__PURE__ */ new P(), yt = /* @__PURE__ */ new Cn(), hi = /* @__PURE__ */ new Cn(), ut = /* @__PURE__ */ new P();
class hn extends Rn {
  constructor() {
    super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: lc++ }), this.uuid = vi(), this.name = "", this.type = "BufferGeometry", this.index = null, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { start: 0, count: 1 / 0 }, this.userData = {};
  }
  getIndex() {
    return this.index;
  }
  setIndex(e) {
    return Array.isArray(e) ? this.index = new (Mo(e) ? Ro : wo)(e, 1) : this.index = e, this;
  }
  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) {
    const t = this.attributes.position;
    t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0);
    const n = this.attributes.normal;
    if (n !== void 0) {
      const s = new Ve().getNormalMatrix(e);
      n.applyNormalMatrix(s), n.needsUpdate = !0;
    }
    const 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;
  }
  applyQuaternion(e) {
    return wt.makeRotationFromQuaternion(e), this.applyMatrix4(wt), this;
  }
  rotateX(e) {
    return wt.makeRotationX(e), this.applyMatrix4(wt), this;
  }
  rotateY(e) {
    return wt.makeRotationY(e), this.applyMatrix4(wt), this;
  }
  rotateZ(e) {
    return wt.makeRotationZ(e), this.applyMatrix4(wt), this;
  }
  translate(e, t, n) {
    return wt.makeTranslation(e, t, n), this.applyMatrix4(wt), this;
  }
  scale(e, t, n) {
    return wt.makeScale(e, t, n), this.applyMatrix4(wt), this;
  }
  lookAt(e) {
    return Nr.lookAt(e), Nr.updateMatrix(), this.applyMatrix4(Nr.matrix), this;
  }
  center() {
    return this.computeBoundingBox(), this.boundingBox.getCenter(Hn).negate(), this.translate(Hn.x, Hn.y, Hn.z), this;
  }
  setFromPoints(e) {
    const t = [];
    for (let n = 0, r = e.length; n < r; n++) {
      const s = e[n];
      t.push(s.x, s.y, s.z || 0);
    }
    return this.setAttribute("position", new Ht(t, 3)), this;
  }
  computeBoundingBox() {
    this.boundingBox === null && (this.boundingBox = new Cn());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingBox.set(
        new P(-1 / 0, -1 / 0, -1 / 0),
        new P(1 / 0, 1 / 0, 1 / 0)
      );
      return;
    }
    if (e !== void 0) {
      if (this.boundingBox.setFromBufferAttribute(e), t)
        for (let n = 0, r = t.length; n < r; n++) {
          const s = t[n];
          yt.setFromBufferAttribute(s), this.morphTargetsRelative ? (ut.addVectors(this.boundingBox.min, yt.min), this.boundingBox.expandByPoint(ut), ut.addVectors(this.boundingBox.max, yt.max), this.boundingBox.expandByPoint(ut)) : (this.boundingBox.expandByPoint(yt.min), this.boundingBox.expandByPoint(yt.max));
        }
    } else
      this.boundingBox.makeEmpty();
    (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.', this);
  }
  computeBoundingSphere() {
    this.boundingSphere === null && (this.boundingSphere = new xi());
    const e = this.attributes.position, t = this.morphAttributes.position;
    if (e && e.isGLBufferAttribute) {
      console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".', this), this.boundingSphere.set(new P(), 1 / 0);
      return;
    }
    if (e) {
      const n = this.boundingSphere.center;
      if (yt.setFromBufferAttribute(e), t)
        for (let s = 0, o = t.length; s < o; s++) {
          const a = t[s];
          hi.setFromBufferAttribute(a), this.morphTargetsRelative ? (ut.addVectors(yt.min, hi.min), yt.expandByPoint(ut), ut.addVectors(yt.max, hi.max), yt.expandByPoint(ut)) : (yt.expandByPoint(hi.min), yt.expandByPoint(hi.max));
        }
      yt.getCenter(n);
      let r = 0;
      for (let s = 0, o = e.count; s < o; s++)
        ut.fromBufferAttribute(e, s), r = Math.max(r, n.distanceToSquared(ut));
      if (t)
        for (let s = 0, o = t.length; s < o; s++) {
          const a = t[s], l = this.morphTargetsRelative;
          for (let c = 0, h = a.count; c < h; c++)
            ut.fromBufferAttribute(a, c), l && (Hn.fromBufferAttribute(e, c), ut.add(Hn)), r = Math.max(r, n.distanceToSquared(ut));
        }
      this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.', this);
    }
  }
  computeTangents() {
    const e = this.index, t = this.attributes;
    if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) {
      console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");
      return;
    }
    const n = e.array, r = t.position.array, s = t.normal.array, o = t.uv.array, a = r.length / 3;
    this.hasAttribute("tangent") === !1 && this.setAttribute("tangent", new Bt(new Float32Array(4 * a), 4));
    const l = this.getAttribute("tangent").array, c = [], h = [];
    for (let y = 0; y < a; y++)
      c[y] = new P(), h[y] = new P();
    const d = new P(), p = new P(), m = new P(), g = new Ie(), v = new Ie(), f = new Ie(), u = new P(), b = new P();
    function S(y, z, Z) {
      d.fromArray(r, y * 3), p.fromArray(r, z * 3), m.fromArray(r, Z * 3), g.fromArray(o, y * 2), v.fromArray(o, z * 2), f.fromArray(o, Z * 2), p.sub(d), m.sub(d), v.sub(g), f.sub(g);
      const re = 1 / (v.x * f.y - f.x * v.y);
      isFinite(re) && (u.copy(p).multiplyScalar(f.y).addScaledVector(m, -v.y).multiplyScalar(re), b.copy(m).multiplyScalar(v.x).addScaledVector(p, -f.x).multiplyScalar(re), c[y].add(u), c[z].add(u), c[Z].add(u), h[y].add(b), h[z].add(b), h[Z].add(b));
    }
    let R = this.groups;
    R.length === 0 && (R = [{
      start: 0,
      count: n.length
    }]);
    for (let y = 0, z = R.length; y < z; ++y) {
      const Z = R[y], re = Z.start, L = Z.count;
      for (let F = re, V = re + L; F < V; F += 3)
        S(
          n[F + 0],
          n[F + 1],
          n[F + 2]
        );
    }
    const D = new P(), C = new P(), A = new P(), W = new P();
    function x(y) {
      A.fromArray(s, y * 3), W.copy(A);
      const z = c[y];
      D.copy(z), D.sub(A.multiplyScalar(A.dot(z))).normalize(), C.crossVectors(W, z);
      const re = C.dot(h[y]) < 0 ? -1 : 1;
      l[y * 4] = D.x, l[y * 4 + 1] = D.y, l[y * 4 + 2] = D.z, l[y * 4 + 3] = re;
    }
    for (let y = 0, z = R.length; y < z; ++y) {
      const Z = R[y], re = Z.start, L = Z.count;
      for (let F = re, V = re + L; F < V; F += 3)
        x(n[F + 0]), x(n[F + 1]), x(n[F + 2]);
    }
  }
  computeVertexNormals() {
    const e = this.index, t = this.getAttribute("position");
    if (t !== void 0) {
      let n = this.getAttribute("normal");
      if (n === void 0)
        n = new Bt(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n);
      else
        for (let p = 0, m = n.count; p < m; p++)
          n.setXYZ(p, 0, 0, 0);
      const r = new P(), s = new P(), o = new P(), a = new P(), l = new P(), c = new P(), h = new P(), d = new P();
      if (e)
        for (let p = 0, m = e.count; p < m; p += 3) {
          const g = e.getX(p + 0), v = e.getX(p + 1), f = e.getX(p + 2);
          r.fromBufferAttribute(t, g), s.fromBufferAttribute(t, v), o.fromBufferAttribute(t, f), h.subVectors(o, s), d.subVectors(r, s), h.cross(d), a.fromBufferAttribute(n, g), l.fromBufferAttribute(n, v), c.fromBufferAttribute(n, f), a.add(h), l.add(h), c.add(h), n.setXYZ(g, a.x, a.y, a.z), n.setXYZ(v, l.x, l.y, l.z), n.setXYZ(f, c.x, c.y, c.z);
        }
      else
        for (let p = 0, m = t.count; p < m; p += 3)
          r.fromBufferAttribute(t, p + 0), s.fromBufferAttribute(t, p + 1), o.fromBufferAttribute(t, p + 2), h.subVectors(o, s), d.subVectors(r, s), h.cross(d), n.setXYZ(p + 0, h.x, h.y, h.z), n.setXYZ(p + 1, h.x, h.y, h.z), n.setXYZ(p + 2, h.x, h.y, h.z);
      this.normalizeNormals(), n.needsUpdate = !0;
    }
  }
  normalizeNormals() {
    const e = this.attributes.normal;
    for (let t = 0, n = e.count; t < n; t++)
      ut.fromBufferAttribute(e, t), ut.normalize(), e.setXYZ(t, ut.x, ut.y, ut.z);
  }
  toNonIndexed() {
    function e(a, l) {
      const c = a.array, h = a.itemSize, d = a.normalized, p = new c.constructor(l.length * h);
      let m = 0, g = 0;
      for (let v = 0, f = l.length; v < f; v++) {
        a.isInterleavedBufferAttribute ? m = l[v] * a.data.stride + a.offset : m = l[v] * h;
        for (let u = 0; u < h; u++)
          p[g++] = c[m++];
      }
      return new Bt(p, h, d);
    }
    if (this.index === null)
      return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this;
    const t = new hn(), n = this.index.array, r = this.attributes;
    for (const a in r) {
      const l = r[a], c = e(l, n);
      t.setAttribute(a, c);
    }
    const s = this.morphAttributes;
    for (const a in s) {
      const l = [], c = s[a];
      for (let h = 0, d = c.length; h < d; h++) {
        const p = c[h], m = e(p, n);
        l.push(m);
      }
      t.morphAttributes[a] = l;
    }
    t.morphTargetsRelative = this.morphTargetsRelative;
    const o = this.groups;
    for (let a = 0, l = o.length; a < l; a++) {
      const c = o[a];
      t.addGroup(c.start, c.count, c.materialIndex);
    }
    return t;
  }
  toJSON() {
    const e = {
      metadata: {
        version: 4.6,
        type: "BufferGeometry",
        generator: "BufferGeometry.toJSON"
      }
    };
    if (e.uuid = this.uuid, e.type = this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0) {
      const l = this.parameters;
      for (const c in l)
        l[c] !== void 0 && (e[c] = l[c]);
      return e;
    }
    e.data = { attributes: {} };
    const t = this.index;
    t !== null && (e.data.index = {
      type: t.array.constructor.name,
      array: Array.prototype.slice.call(t.array)
    });
    const n = this.attributes;
    for (const l in n) {
      const c = n[l];
      e.data.attributes[l] = c.toJSON(e.data);
    }
    const r = {};
    let s = !1;
    for (const l in this.morphAttributes) {
      const c = this.morphAttributes[l], h = [];
      for (let d = 0, p = c.length; d < p; d++) {
        const m = c[d];
        h.push(m.toJSON(e.data));
      }
      h.length > 0 && (r[l] = h, s = !0);
    }
    s && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative);
    const o = this.groups;
    o.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(o)));
    const a = this.boundingSphere;
    return a !== null && (e.data.boundingSphere = {
      center: a.center.toArray(),
      radius: a.radius
    }), 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;
    const t = {};
    this.name = e.name;
    const n = e.index;
    n !== null && this.setIndex(n.clone(t));
    const r = e.attributes;
    for (const c in r) {
      const h = r[c];
      this.setAttribute(c, h.clone(t));
    }
    const s = e.morphAttributes;
    for (const c in s) {
      const h = [], d = s[c];
      for (let p = 0, m = d.length; p < m; p++)
        h.push(d[p].clone(t));
      this.morphAttributes[c] = h;
    }
    this.morphTargetsRelative = e.morphTargetsRelative;
    const o = e.groups;
    for (let c = 0, h = o.length; c < h; c++) {
      const d = o[c];
      this.addGroup(d.start, d.count, d.materialIndex);
    }
    const a = e.boundingBox;
    a !== null && (this.boundingBox = a.clone());
    const l = e.boundingSphere;
    return l !== null && (this.boundingSphere = l.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this;
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
const pa = /* @__PURE__ */ new Qe(), gn = /* @__PURE__ */ new To(), Ni = /* @__PURE__ */ new xi(), ma = /* @__PURE__ */ new P(), Vn = /* @__PURE__ */ new P(), kn = /* @__PURE__ */ new P(), Wn = /* @__PURE__ */ new P(), Fr = /* @__PURE__ */ new P(), Fi = /* @__PURE__ */ new P(), Oi = /* @__PURE__ */ new Ie(), Bi = /* @__PURE__ */ new Ie(), zi = /* @__PURE__ */ new Ie(), _a = /* @__PURE__ */ new P(), ga = /* @__PURE__ */ new P(), va = /* @__PURE__ */ new P(), Gi = /* @__PURE__ */ new P(), Hi = /* @__PURE__ */ new P();
class Ot extends dt {
  constructor(e = new hn(), t = new ls()) {
    super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, 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() {
    const t = this.geometry.morphAttributes, n = Object.keys(t);
    if (n.length > 0) {
      const r = t[n[0]];
      if (r !== void 0) {
        this.morphTargetInfluences = [], this.morphTargetDictionary = {};
        for (let s = 0, o = r.length; s < o; s++) {
          const a = r[s].name || String(s);
          this.morphTargetInfluences.push(0), this.morphTargetDictionary[a] = s;
        }
      }
    }
  }
  getVertexPosition(e, t) {
    const n = this.geometry, r = n.attributes.position, s = n.morphAttributes.position, o = n.morphTargetsRelative;
    t.fromBufferAttribute(r, e);
    const a = this.morphTargetInfluences;
    if (s && a) {
      Fi.set(0, 0, 0);
      for (let l = 0, c = s.length; l < c; l++) {
        const h = a[l], d = s[l];
        h !== 0 && (Fr.fromBufferAttribute(d, e), o ? Fi.addScaledVector(Fr, h) : Fi.addScaledVector(Fr.sub(t), h));
      }
      t.add(Fi);
    }
    return t;
  }
  raycast(e, t) {
    const n = this.geometry, r = this.material, s = this.matrixWorld;
    r !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Ni.copy(n.boundingSphere), Ni.applyMatrix4(s), gn.copy(e.ray).recast(e.near), !(Ni.containsPoint(gn.origin) === !1 && (gn.intersectSphere(Ni, ma) === null || gn.origin.distanceToSquared(ma) > (e.far - e.near) ** 2)) && (pa.copy(s).invert(), gn.copy(e.ray).applyMatrix4(pa), !(n.boundingBox !== null && gn.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, gn)));
  }
  _computeIntersections(e, t, n) {
    let r;
    const s = this.geometry, o = this.material, a = s.index, l = s.attributes.position, c = s.attributes.uv, h = s.attributes.uv1, d = s.attributes.normal, p = s.groups, m = s.drawRange;
    if (a !== null)
      if (Array.isArray(o))
        for (let g = 0, v = p.length; g < v; g++) {
          const f = p[g], u = o[f.materialIndex], b = Math.max(f.start, m.start), S = Math.min(a.count, Math.min(f.start + f.count, m.start + m.count));
          for (let R = b, D = S; R < D; R += 3) {
            const C = a.getX(R), A = a.getX(R + 1), W = a.getX(R + 2);
            r = Vi(this, u, e, n, c, h, d, C, A, W), r && (r.faceIndex = Math.floor(R / 3), r.face.materialIndex = f.materialIndex, t.push(r));
          }
        }
      else {
        const g = Math.max(0, m.start), v = Math.min(a.count, m.start + m.count);
        for (let f = g, u = v; f < u; f += 3) {
          const b = a.getX(f), S = a.getX(f + 1), R = a.getX(f + 2);
          r = Vi(this, o, e, n, c, h, d, b, S, R), r && (r.faceIndex = Math.floor(f / 3), t.push(r));
        }
      }
    else if (l !== void 0)
      if (Array.isArray(o))
        for (let g = 0, v = p.length; g < v; g++) {
          const f = p[g], u = o[f.materialIndex], b = Math.max(f.start, m.start), S = Math.min(l.count, Math.min(f.start + f.count, m.start + m.count));
          for (let R = b, D = S; R < D; R += 3) {
            const C = R, A = R + 1, W = R + 2;
            r = Vi(this, u, e, n, c, h, d, C, A, W), r && (r.faceIndex = Math.floor(R / 3), r.face.materialIndex = f.materialIndex, t.push(r));
          }
        }
      else {
        const g = Math.max(0, m.start), v = Math.min(l.count, m.start + m.count);
        for (let f = g, u = v; f < u; f += 3) {
          const b = f, S = f + 1, R = f + 2;
          r = Vi(this, o, e, n, c, h, d, b, S, R), r && (r.faceIndex = Math.floor(f / 3), t.push(r));
        }
      }
  }
}
function cc(i, e, t, n, r, s, o, a) {
  let l;
  if (e.side === Mt ? l = n.intersectTriangle(o, s, r, !0, a) : l = n.intersectTriangle(r, s, o, e.side === un, a), l === null) return null;
  Hi.copy(a), Hi.applyMatrix4(i.matrixWorld);
  const c = t.ray.origin.distanceTo(Hi);
  return c < t.near || c > t.far ? null : {
    distance: c,
    point: Hi.clone(),
    object: i
  };
}
function Vi(i, e, t, n, r, s, o, a, l, c) {
  i.getVertexPosition(a, Vn), i.getVertexPosition(l, kn), i.getVertexPosition(c, Wn);
  const h = cc(i, e, t, n, Vn, kn, Wn, Gi);
  if (h) {
    r && (Oi.fromBufferAttribute(r, a), Bi.fromBufferAttribute(r, l), zi.fromBufferAttribute(r, c), h.uv = It.getInterpolation(Gi, Vn, kn, Wn, Oi, Bi, zi, new Ie())), s && (Oi.fromBufferAttribute(s, a), Bi.fromBufferAttribute(s, l), zi.fromBufferAttribute(s, c), h.uv1 = It.getInterpolation(Gi, Vn, kn, Wn, Oi, Bi, zi, new Ie()), h.uv2 = h.uv1), o && (_a.fromBufferAttribute(o, a), ga.fromBufferAttribute(o, l), va.fromBufferAttribute(o, c), h.normal = It.getInterpolation(Gi, Vn, kn, Wn, _a, ga, va, new P()), h.normal.dot(n.direction) > 0 && h.normal.multiplyScalar(-1));
    const d = {
      a,
      b: l,
      c,
      normal: new P(),
      materialIndex: 0
    };
    It.getNormal(Vn, kn, Wn, d.normal), h.face = d;
  }
  return h;
}
class ii extends hn {
  constructor(e = 1, t = 1, n = 1, r = 1, s = 1, o = 1) {
    super(), this.type = "BoxGeometry", this.parameters = {
      width: e,
      height: t,
      depth: n,
      widthSegments: r,
      heightSegments: s,
      depthSegments: o
    };
    const a = this;
    r = Math.floor(r), s = Math.floor(s), o = Math.floor(o);
    const l = [], c = [], h = [], d = [];
    let p = 0, m = 0;
    g("z", "y", "x", -1, -1, n, t, e, o, s, 0), g("z", "y", "x", 1, -1, n, t, -e, o, s, 1), g("x", "z", "y", 1, 1, e, n, t, r, o, 2), g("x", "z", "y", 1, -1, e, n, -t, r, o, 3), g("x", "y", "z", 1, -1, e, t, n, r, s, 4), g("x", "y", "z", -1, -1, e, t, -n, r, s, 5), this.setIndex(l), this.setAttribute("position", new Ht(c, 3)), this.setAttribute("normal", new Ht(h, 3)), this.setAttribute("uv", new Ht(d, 2));
    function g(v, f, u, b, S, R, D, C, A, W, x) {
      const y = R / A, z = D / W, Z = R / 2, re = D / 2, L = C / 2, F = A + 1, V = W + 1;
      let Y = 0, X = 0;
      const k = new P();
      for (let q = 0; q < V; q++) {
        const Q = q * z - re;
        for (let ce = 0; ce < F; ce++) {
          const H = ce * y - Z;
          k[v] = H * b, k[f] = Q * S, k[u] = L, c.push(k.x, k.y, k.z), k[v] = 0, k[f] = 0, k[u] = C > 0 ? 1 : -1, h.push(k.x, k.y, k.z), d.push(ce / A), d.push(1 - q / W), Y += 1;
        }
      }
      for (let q = 0; q < W; q++)
        for (let Q = 0; Q < A; Q++) {
          const ce = p + Q + F * q, H = p + Q + F * (q + 1), j = p + (Q + 1) + F * (q + 1), oe = p + (Q + 1) + F * q;
          l.push(ce, H, oe), l.push(H, j, oe), X += 6;
        }
      a.addGroup(m, X, x), m += X, p += Y;
    }
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new ii(e.width, e.height, e.depth, e.widthSegments, e.heightSegments, e.depthSegments);
  }
}
function ni(i) {
  const e = {};
  for (const t in i) {
    e[t] = {};
    for (const n in i[t]) {
      const r = i[t][n];
      r && (r.isColor || r.isMatrix3 || r.isMatrix4 || r.isVector2 || r.isVector3 || r.isVector4 || r.isTexture || r.isQuaternion) ? r.isRenderTargetTexture ? (console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), e[t][n] = null) : e[t][n] = r.clone() : Array.isArray(r) ? e[t][n] = r.slice() : e[t][n] = r;
    }
  }
  return e;
}
function _t(i) {
  const e = {};
  for (let t = 0; t < i.length; t++) {
    const n = ni(i[t]);
    for (const r in n)
      e[r] = n[r];
  }
  return e;
}
function uc(i) {
  const e = [];
  for (let t = 0; t < i.length; t++)
    e.push(i[t].clone());
  return e;
}
function Co(i) {
  return i.getRenderTarget() === null ? i.outputColorSpace : Ke.workingColorSpace;
}
const hc = { clone: ni, merge: _t };
var dc = `void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`, fc = `void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;
class wn extends Mi {
  constructor(e) {
    super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = dc, this.fragmentShader = fc, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = {
      derivatives: !1,
      // set to use derivatives
      fragDepth: !1,
      // set to use fragment depth values
      drawBuffers: !1,
      // set to use draw buffers
      shaderTextureLOD: !1,
      // set to use shader texture LOD
      clipCullDistance: !1
      // set to use vertex shader clipping
    }, 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 = ni(e.uniforms), this.uniformsGroups = uc(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    t.glslVersion = this.glslVersion, t.uniforms = {};
    for (const r in this.uniforms) {
      const o = this.uniforms[r].value;
      o && o.isTexture ? t.uniforms[r] = {
        type: "t",
        value: o.toJSON(e).uuid
      } : o && o.isColor ? t.uniforms[r] = {
        type: "c",
        value: o.getHex()
      } : o && o.isVector2 ? t.uniforms[r] = {
        type: "v2",
        value: o.toArray()
      } : o && o.isVector3 ? t.uniforms[r] = {
        type: "v3",
        value: o.toArray()
      } : o && o.isVector4 ? t.uniforms[r] = {
        type: "v4",
        value: o.toArray()
      } : o && o.isMatrix3 ? t.uniforms[r] = {
        type: "m3",
        value: o.toArray()
      } : o && o.isMatrix4 ? t.uniforms[r] = {
        type: "m4",
        value: o.toArray()
      } : t.uniforms[r] = {
        value: o
      };
    }
    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;
    const n = {};
    for (const r in this.extensions)
      this.extensions[r] === !0 && (n[r] = !0);
    return Object.keys(n).length > 0 && (t.extensions = n), t;
  }
}
class Lo extends dt {
  constructor() {
    super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new Qe(), this.projectionMatrix = new Qe(), this.projectionMatrixInverse = new Qe(), this.coordinateSystem = Zt;
  }
  copy(e, t) {
    return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this.coordinateSystem = e.coordinateSystem, this;
  }
  getWorldDirection(e) {
    return super.getWorldDirection(e).negate();
  }
  updateMatrixWorld(e) {
    super.updateMatrixWorld(e), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  updateWorldMatrix(e, t) {
    super.updateWorldMatrix(e, t), this.matrixWorldInverse.copy(this.matrixWorld).invert();
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
class Tt extends Lo {
  constructor(e = 50, t = 1, n = 0.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;
  }
  /**
   * Sets the FOV by focal length in respect to the current .filmGauge.
   *
   * The default film gauge is 35, so that the focal length can be specified for
   * a 35mm (full frame) camera.
   *
   * Values for focal length and film gauge must have the same unit.
   */
  setFocalLength(e) {
    const t = 0.5 * this.getFilmHeight() / e;
    this.fov = ns * 2 * Math.atan(t), this.updateProjectionMatrix();
  }
  /**
   * Calculates the focal length from the current .fov and .filmGauge.
   */
  getFocalLength() {
    const e = Math.tan(Ki * 0.5 * this.fov);
    return 0.5 * this.getFilmHeight() / e;
  }
  getEffectiveFOV() {
    return ns * 2 * Math.atan(
      Math.tan(Ki * 0.5 * this.fov) / this.zoom
    );
  }
  getFilmWidth() {
    return this.filmGauge * Math.min(this.aspect, 1);
  }
  getFilmHeight() {
    return this.filmGauge / Math.max(this.aspect, 1);
  }
  /**
   * Sets an offset in a larger frustum. This is useful for multi-window or
   * multi-monitor/multi-machine setups.
   *
   * For example, if you have 3x2 monitors and each monitor is 1920x1080 and
   * the monitors are in grid like this
   *
   *   +---+---+---+
   *   | A | B | C |
   *   +---+---+---+
   *   | D | E | F |
   *   +---+---+---+
   *
   * then for each monitor you would call it like this
   *
   *   const w = 1920;
   *   const h = 1080;
   *   const fullWidth = w * 3;
   *   const fullHeight = h * 2;
   *
   *   --A--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
   *   --B--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
   *   --C--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
   *   --D--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
   *   --E--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
   *   --F--
   *   camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
   *
   *   Note there is no reason monitors have to be the same size or in a grid.
   */
  setViewOffset(e, t, n, r, s, o) {
    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 = s, this.view.height = o, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const e = this.near;
    let t = e * Math.tan(Ki * 0.5 * this.fov) / this.zoom, n = 2 * t, r = this.aspect * n, s = -0.5 * r;
    const o = this.view;
    if (this.view !== null && this.view.enabled) {
      const l = o.fullWidth, c = o.fullHeight;
      s += o.offsetX * r / l, t -= o.offsetY * n / c, r *= o.width / l, n *= o.height / c;
    }
    const a = this.filmOffset;
    a !== 0 && (s += e * a / this.getFilmWidth()), this.projectionMatrix.makePerspective(s, s + r, t, t - n, e, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const 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;
  }
}
const Xn = -90, qn = 1;
class pc extends dt {
  constructor(e, t, n) {
    super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0;
    const r = new Tt(Xn, qn, e, t);
    r.layers = this.layers, this.add(r);
    const s = new Tt(Xn, qn, e, t);
    s.layers = this.layers, this.add(s);
    const o = new Tt(Xn, qn, e, t);
    o.layers = this.layers, this.add(o);
    const a = new Tt(Xn, qn, e, t);
    a.layers = this.layers, this.add(a);
    const l = new Tt(Xn, qn, e, t);
    l.layers = this.layers, this.add(l);
    const c = new Tt(Xn, qn, e, t);
    c.layers = this.layers, this.add(c);
  }
  updateCoordinateSystem() {
    const e = this.coordinateSystem, t = this.children.concat(), [n, r, s, o, a, l] = t;
    for (const c of t) this.remove(c);
    if (e === Zt)
      n.up.set(0, 1, 0), n.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), s.up.set(0, 0, -1), s.lookAt(0, 1, 0), o.up.set(0, 0, 1), o.lookAt(0, -1, 0), a.up.set(0, 1, 0), a.lookAt(0, 0, 1), l.up.set(0, 1, 0), l.lookAt(0, 0, -1);
    else if (e === tr)
      n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), s.up.set(0, 0, 1), s.lookAt(0, 1, 0), o.up.set(0, 0, -1), o.lookAt(0, -1, 0), a.up.set(0, -1, 0), a.lookAt(0, 0, 1), l.up.set(0, -1, 0), l.lookAt(0, 0, -1);
    else
      throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e);
    for (const c of t)
      this.add(c), c.updateMatrixWorld();
  }
  update(e, t) {
    this.parent === null && this.updateMatrixWorld();
    const { renderTarget: n, activeMipmapLevel: r } = this;
    this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem());
    const [s, o, a, l, c, h] = this.children, d = e.getRenderTarget(), p = e.getActiveCubeFace(), m = e.getActiveMipmapLevel(), g = e.xr.enabled;
    e.xr.enabled = !1;
    const v = n.texture.generateMipmaps;
    n.texture.generateMipmaps = !1, e.setRenderTarget(n, 0, r), e.render(t, s), e.setRenderTarget(n, 1, r), e.render(t, o), e.setRenderTarget(n, 2, r), e.render(t, a), e.setRenderTarget(n, 3, r), e.render(t, l), e.setRenderTarget(n, 4, r), e.render(t, c), n.texture.generateMipmaps = v, e.setRenderTarget(n, 5, r), e.render(t, h), e.setRenderTarget(d, p, m), e.xr.enabled = g, n.texture.needsPMREMUpdate = !0;
  }
}
class Po extends bt {
  constructor(e, t, n, r, s, o, a, l, c, h) {
    e = e !== void 0 ? e : [], t = t !== void 0 ? t : Qn, super(e, t, n, r, s, o, a, l, c, h), this.isCubeTexture = !0, this.flipY = !1;
  }
  get images() {
    return this.image;
  }
  set images(e) {
    this.image = e;
  }
}
class mc extends bn {
  constructor(e = 1, t = {}) {
    super(e, e, t), this.isWebGLCubeRenderTarget = !0;
    const n = { width: e, height: e, depth: 1 }, r = [n, n, n, n, n, n];
    t.encoding !== void 0 && (mi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."), t.colorSpace = t.encoding === Tn ? ht : Ct), this.texture = new Po(r, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace), this.texture.isRenderTargetTexture = !0, this.texture.generateMipmaps = t.generateMipmaps !== void 0 ? t.generateMipmaps : !1, this.texture.minFilter = t.minFilter !== void 0 ? t.minFilter : Rt;
  }
  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;
    const n = {
      uniforms: {
        tEquirect: { value: null }
      },
      vertexShader: (
        /* glsl */
        `

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`
      ),
      fragmentShader: (
        /* glsl */
        `

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`
      )
    }, r = new ii(5, 5, 5), s = new wn({
      name: "CubemapFromEquirect",
      uniforms: ni(n.uniforms),
      vertexShader: n.vertexShader,
      fragmentShader: n.fragmentShader,
      side: Mt,
      blending: on
    });
    s.uniforms.tEquirect.value = t;
    const o = new Ot(r, s), a = t.minFilter;
    return t.minFilter === _i && (t.minFilter = Rt), new pc(1, 10, this).update(e, o), t.minFilter = a, o.geometry.dispose(), o.material.dispose(), this;
  }
  clear(e, t, n, r) {
    const s = e.getRenderTarget();
    for (let o = 0; o < 6; o++)
      e.setRenderTarget(this, o), e.clear(t, n, r);
    e.setRenderTarget(s);
  }
}
const Or = /* @__PURE__ */ new P(), _c = /* @__PURE__ */ new P(), gc = /* @__PURE__ */ new Ve();
class rn {
  constructor(e = new P(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) {
    const r = Or.subVectors(n, t).cross(_c.subVectors(e, t)).normalize();
    return this.setFromNormalAndCoplanarPoint(r, e), this;
  }
  copy(e) {
    return this.normal.copy(e.normal), this.constant = e.constant, this;
  }
  normalize() {
    const 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) {
    const n = e.delta(Or), r = this.normal.dot(n);
    if (r === 0)
      return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null;
    const s = -(e.start.dot(this.normal) + this.constant) / r;
    return s < 0 || s > 1 ? null : t.copy(e.start).addScaledVector(n, s);
  }
  intersectsLine(e) {
    const 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) {
    const n = t || gc.getNormalMatrix(e), r = this.coplanarPoint(Or).applyMatrix4(e), s = this.normal.applyMatrix3(n).normalize();
    return this.constant = -r.dot(s), this;
  }
  translate(e) {
    return this.constant -= e.dot(this.normal), this;
  }
  equals(e) {
    return e.normal.equals(this.normal) && e.constant === this.constant;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
const vn = /* @__PURE__ */ new xi(), ki = /* @__PURE__ */ new P();
class cs {
  constructor(e = new rn(), t = new rn(), n = new rn(), r = new rn(), s = new rn(), o = new rn()) {
    this.planes = [e, t, n, r, s, o];
  }
  set(e, t, n, r, s, o) {
    const a = this.planes;
    return a[0].copy(e), a[1].copy(t), a[2].copy(n), a[3].copy(r), a[4].copy(s), a[5].copy(o), this;
  }
  copy(e) {
    const t = this.planes;
    for (let n = 0; n < 6; n++)
      t[n].copy(e.planes[n]);
    return this;
  }
  setFromProjectionMatrix(e, t = Zt) {
    const n = this.planes, r = e.elements, s = r[0], o = r[1], a = r[2], l = r[3], c = r[4], h = r[5], d = r[6], p = r[7], m = r[8], g = r[9], v = r[10], f = r[11], u = r[12], b = r[13], S = r[14], R = r[15];
    if (n[0].setComponents(l - s, p - c, f - m, R - u).normalize(), n[1].setComponents(l + s, p + c, f + m, R + u).normalize(), n[2].setComponents(l + o, p + h, f + g, R + b).normalize(), n[3].setComponents(l - o, p - h, f - g, R - b).normalize(), n[4].setComponents(l - a, p - d, f - v, R - S).normalize(), t === Zt)
      n[5].setComponents(l + a, p + d, f + v, R + S).normalize();
    else if (t === tr)
      n[5].setComponents(a, d, v, S).normalize();
    else
      throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t);
    return this;
  }
  intersectsObject(e) {
    if (e.boundingSphere !== void 0)
      e.boundingSphere === null && e.computeBoundingSphere(), vn.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);
    else {
      const t = e.geometry;
      t.boundingSphere === null && t.computeBoundingSphere(), vn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld);
    }
    return this.intersectsSphere(vn);
  }
  intersectsSprite(e) {
    return vn.center.set(0, 0, 0), vn.radius = 0.7071067811865476, vn.applyMatrix4(e.matrixWorld), this.intersectsSphere(vn);
  }
  intersectsSphere(e) {
    const t = this.planes, n = e.center, r = -e.radius;
    for (let s = 0; s < 6; s++)
      if (t[s].distanceToPoint(n) < r)
        return !1;
    return !0;
  }
  intersectsBox(e) {
    const t = this.planes;
    for (let n = 0; n < 6; n++) {
      const r = t[n];
      if (ki.x = r.normal.x > 0 ? e.max.x : e.min.x, ki.y = r.normal.y > 0 ? e.max.y : e.min.y, ki.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(ki) < 0)
        return !1;
    }
    return !0;
  }
  containsPoint(e) {
    const 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);
  }
}
function Do() {
  let i = null, e = !1, t = null, n = null;
  function r(s, o) {
    t(s, o), n = i.requestAnimationFrame(r);
  }
  return {
    start: function() {
      e !== !0 && t !== null && (n = i.requestAnimationFrame(r), e = !0);
    },
    stop: function() {
      i.cancelAnimationFrame(n), e = !1;
    },
    setAnimationLoop: function(s) {
      t = s;
    },
    setContext: function(s) {
      i = s;
    }
  };
}
function vc(i, e) {
  const t = e.isWebGL2, n = /* @__PURE__ */ new WeakMap();
  function r(c, h) {
    const d = c.array, p = c.usage, m = d.byteLength, g = i.createBuffer();
    i.bindBuffer(h, g), i.bufferData(h, d, p), c.onUploadCallback();
    let v;
    if (d instanceof Float32Array)
      v = i.FLOAT;
    else if (d instanceof Uint16Array)
      if (c.isFloat16BufferAttribute)
        if (t)
          v = i.HALF_FLOAT;
        else
          throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");
      else
        v = i.UNSIGNED_SHORT;
    else if (d instanceof Int16Array)
      v = i.SHORT;
    else if (d instanceof Uint32Array)
      v = i.UNSIGNED_INT;
    else if (d instanceof Int32Array)
      v = i.INT;
    else if (d instanceof Int8Array)
      v = i.BYTE;
    else if (d instanceof Uint8Array)
      v = i.UNSIGNED_BYTE;
    else if (d instanceof Uint8ClampedArray)
      v = i.UNSIGNED_BYTE;
    else
      throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: " + d);
    return {
      buffer: g,
      type: v,
      bytesPerElement: d.BYTES_PER_ELEMENT,
      version: c.version,
      size: m
    };
  }
  function s(c, h, d) {
    const p = h.array, m = h._updateRange, g = h.updateRanges;
    if (i.bindBuffer(d, c), m.count === -1 && g.length === 0 && i.bufferSubData(d, 0, p), g.length !== 0) {
      for (let v = 0, f = g.length; v < f; v++) {
        const u = g[v];
        t ? i.bufferSubData(
          d,
          u.start * p.BYTES_PER_ELEMENT,
          p,
          u.start,
          u.count
        ) : i.bufferSubData(
          d,
          u.start * p.BYTES_PER_ELEMENT,
          p.subarray(u.start, u.start + u.count)
        );
      }
      h.clearUpdateRanges();
    }
    m.count !== -1 && (t ? i.bufferSubData(
      d,
      m.offset * p.BYTES_PER_ELEMENT,
      p,
      m.offset,
      m.count
    ) : i.bufferSubData(
      d,
      m.offset * p.BYTES_PER_ELEMENT,
      p.subarray(m.offset, m.offset + m.count)
    ), m.count = -1), h.onUploadCallback();
  }
  function o(c) {
    return c.isInterleavedBufferAttribute && (c = c.data), n.get(c);
  }
  function a(c) {
    c.isInterleavedBufferAttribute && (c = c.data);
    const h = n.get(c);
    h && (i.deleteBuffer(h.buffer), n.delete(c));
  }
  function l(c, h) {
    if (c.isGLBufferAttribute) {
      const p = n.get(c);
      (!p || p.version < c.version) && n.set(c, {
        buffer: c.buffer,
        type: c.type,
        bytesPerElement: c.elementSize,
        version: c.version
      });
      return;
    }
    c.isInterleavedBufferAttribute && (c = c.data);
    const d = n.get(c);
    if (d === void 0)
      n.set(c, r(c, h));
    else if (d.version < c.version) {
      if (d.size !== c.array.byteLength)
        throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");
      s(d.buffer, c, h), d.version = c.version;
    }
  }
  return {
    get: o,
    remove: a,
    update: l
  };
}
class us extends hn {
  constructor(e = 1, t = 1, n = 1, r = 1) {
    super(), this.type = "PlaneGeometry", this.parameters = {
      width: e,
      height: t,
      widthSegments: n,
      heightSegments: r
    };
    const s = e / 2, o = t / 2, a = Math.floor(n), l = Math.floor(r), c = a + 1, h = l + 1, d = e / a, p = t / l, m = [], g = [], v = [], f = [];
    for (let u = 0; u < h; u++) {
      const b = u * p - o;
      for (let S = 0; S < c; S++) {
        const R = S * d - s;
        g.push(R, -b, 0), v.push(0, 0, 1), f.push(S / a), f.push(1 - u / l);
      }
    }
    for (let u = 0; u < l; u++)
      for (let b = 0; b < a; b++) {
        const S = b + c * u, R = b + c * (u + 1), D = b + 1 + c * (u + 1), C = b + 1 + c * u;
        m.push(S, R, C), m.push(R, D, C);
      }
    this.setIndex(m), this.setAttribute("position", new Ht(g, 3)), this.setAttribute("normal", new Ht(v, 3)), this.setAttribute("uv", new Ht(f, 2));
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new us(e.width, e.height, e.widthSegments, e.heightSegments);
  }
}
var xc = `#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`, Mc = `#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`, Sc = `#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`, Ec = `#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, yc = `#ifdef USE_ALPHATEST
	if ( diffuseColor.a < alphaTest ) discard;
#endif`, Tc = `#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`, bc = `#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`, Ac = `#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`, wc = `#ifdef USE_BATCHING
	attribute float batchId;
	uniform highp sampler2D batchingTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, Rc = `#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( batchId );
#endif`, Cc = `vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`, Lc = `vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`, Pc = `float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`, Dc = `#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`, Uc = `#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`, Ic = `#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#pragma unroll_loop_start
	for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
		plane = clippingPlanes[ i ];
		if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
	}
	#pragma unroll_loop_end
	#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
		bool clipped = true;
		#pragma unroll_loop_start
		for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
		}
		#pragma unroll_loop_end
		if ( clipped ) discard;
	#endif
#endif`, Nc = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`, Fc = `#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`, Oc = `#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`, Bc = `#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`, zc = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`, Gc = `#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	varying vec3 vColor;
#endif`, Hc = `#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif`, Vc = `#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
float luminance( const in vec3 rgb ) {
	const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
	return dot( weights, rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`, kc = `#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`, Wc = `vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`, Xc = `#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`, qc = `#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`, Yc = `#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`, jc = `#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`, Kc = "gl_FragColor = linearToOutputTexel( gl_FragColor );", Zc = `
const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
	vec3( 0.8224621, 0.177538, 0.0 ),
	vec3( 0.0331941, 0.9668058, 0.0 ),
	vec3( 0.0170827, 0.0723974, 0.9105199 )
);
const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
	vec3( 1.2249401, - 0.2249404, 0.0 ),
	vec3( - 0.0420569, 1.0420571, 0.0 ),
	vec3( - 0.0196376, - 0.0786361, 1.0982735 )
);
vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
	return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
}
vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
	return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
}
vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}
vec4 LinearToLinear( in vec4 value ) {
	return value;
}
vec4 LinearTosRGB( in vec4 value ) {
	return sRGBTransferOETF( value );
}`, $c = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`, Jc = `#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`, Qc = `#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`, eu = `#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`, tu = `#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`, nu = `#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`, iu = `#ifdef USE_FOG
	varying float vFogDepth;
#endif`, ru = `#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`, su = `#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`, au = `#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`, ou = `#ifdef USE_LIGHTMAP
	vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
	vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
	reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`, lu = `#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`, cu = `LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`, uu = `varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`, hu = `uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	#if defined ( LEGACY_LIGHTS )
		if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
			return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
		}
		return 1.0;
	#else
		float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
		if ( cutoffDistance > 0.0 ) {
			distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
		}
		return distanceFalloff;
	#endif
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`, du = `#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`, fu = `ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`, pu = `varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`, mu = `BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`, _u = `varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`, gu = `PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`, vu = `struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`, xu = `
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`, Mu = `#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`, Su = `#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`, Eu = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`, yu = `#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`, Tu = `#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		varying float vFragDepth;
		varying float vIsPerspective;
	#else
		uniform float logDepthBufFC;
	#endif
#endif`, bu = `#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		vFragDepth = 1.0 + gl_Position.w;
		vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
	#else
		if ( isPerspectiveMatrix( projectionMatrix ) ) {
			gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
			gl_Position.z *= gl_Position.w;
		}
	#endif
#endif`, Au = `#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`, wu = `#ifdef USE_MAP
	uniform sampler2D map;
#endif`, Ru = `#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`, Cu = `#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`, Lu = `float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`, Pu = `#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`, Du = `#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`, Uu = `#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
		objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
		objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
		objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
	#endif
#endif`, Iu = `#ifdef USE_MORPHTARGETS
	uniform float morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
		uniform sampler2DArray morphTargetsTexture;
		uniform ivec2 morphTargetsTextureSize;
		vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
			int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
			int y = texelIndex / morphTargetsTextureSize.x;
			int x = texelIndex - y * morphTargetsTextureSize.x;
			ivec3 morphUV = ivec3( x, y, morphTargetIndex );
			return texelFetch( morphTargetsTexture, morphUV, 0 );
		}
	#else
		#ifndef USE_MORPHNORMALS
			uniform float morphTargetInfluences[ 8 ];
		#else
			uniform float morphTargetInfluences[ 4 ];
		#endif
	#endif
#endif`, Nu = `#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		transformed += morphTarget0 * morphTargetInfluences[ 0 ];
		transformed += morphTarget1 * morphTargetInfluences[ 1 ];
		transformed += morphTarget2 * morphTargetInfluences[ 2 ];
		transformed += morphTarget3 * morphTargetInfluences[ 3 ];
		#ifndef USE_MORPHNORMALS
			transformed += morphTarget4 * morphTargetInfluences[ 4 ];
			transformed += morphTarget5 * morphTargetInfluences[ 5 ];
			transformed += morphTarget6 * morphTargetInfluences[ 6 ];
			transformed += morphTarget7 * morphTargetInfluences[ 7 ];
		#endif
	#endif
#endif`, Fu = `float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`, Ou = `#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`, Bu = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, zu = `#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`, Gu = `#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`, Hu = `#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`, Vu = `#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`, ku = `#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`, Wu = `#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`, Xu = `#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`, qu = `#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`, Yu = `vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}
vec2 packDepthToRG( in highp float v ) {
	return packDepthToRGBA( v ).yx;
}
float unpackRGToDepth( const in highp vec2 v ) {
	return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
}
vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`, ju = `#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`, Ku = `vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`, Zu = `#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`, $u = `#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`, Ju = `float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`, Qu = `#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`, eh = `#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return shadow;
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
		vec3 lightToPosition = shadowCoord.xyz;
		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );		dp += shadowBias;
		vec3 bd3D = normalize( lightToPosition );
		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
			return (
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
			) * ( 1.0 / 9.0 );
		#else
			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
		#endif
	}
#endif`, th = `#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`, nh = `#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`, ih = `float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`, rh = `#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`, sh = `#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`, ah = `#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`, oh = `#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`, lh = `float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`, ch = `#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`, uh = `#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`, hh = `#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color *= toneMappingExposure;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	return color;
}
vec3 CustomToneMapping( vec3 color ) { return color; }`, dh = `#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`, fh = `#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
		vec3 refractedRayExit = position + transmissionRay;
		vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
		vec2 refractionCoords = ndcPos.xy / ndcPos.w;
		refractionCoords += 1.0;
		refractionCoords /= 2.0;
		vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
		vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`, ph = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, mh = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`, _h = `#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`, gh = `#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;
const vh = `varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`, xh = `uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Mh = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, Sh = `#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Eh = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`, yh = `uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Th = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`, bh = `#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#endif
}`, Ah = `#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`, wh = `#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`, Rh = `varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`, Ch = `uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`, Lh = `uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, Ph = `uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, Dh = `#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`, Uh = `uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Ih = `#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, Nh = `#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Fh = `#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`, Oh = `#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Bh = `#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`, zh = `#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`, Gh = `#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, Hh = `#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Vh = `#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`, kh = `#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, Wh = `#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, Xh = `#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`, qh = `uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`, Yh = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`, jh = `#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`, Kh = `uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, Zh = `uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`, $h = `uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`, Be = {
  alphahash_fragment: xc,
  alphahash_pars_fragment: Mc,
  alphamap_fragment: Sc,
  alphamap_pars_fragment: Ec,
  alphatest_fragment: yc,
  alphatest_pars_fragment: Tc,
  aomap_fragment: bc,
  aomap_pars_fragment: Ac,
  batching_pars_vertex: wc,
  batching_vertex: Rc,
  begin_vertex: Cc,
  beginnormal_vertex: Lc,
  bsdfs: Pc,
  iridescence_fragment: Dc,
  bumpmap_pars_fragment: Uc,
  clipping_planes_fragment: Ic,
  clipping_planes_pars_fragment: Nc,
  clipping_planes_pars_vertex: Fc,
  clipping_planes_vertex: Oc,
  color_fragment: Bc,
  color_pars_fragment: zc,
  color_pars_vertex: Gc,
  color_vertex: Hc,
  common: Vc,
  cube_uv_reflection_fragment: kc,
  defaultnormal_vertex: Wc,
  displacementmap_pars_vertex: Xc,
  displacementmap_vertex: qc,
  emissivemap_fragment: Yc,
  emissivemap_pars_fragment: jc,
  colorspace_fragment: Kc,
  colorspace_pars_fragment: Zc,
  envmap_fragment: $c,
  envmap_common_pars_fragment: Jc,
  envmap_pars_fragment: Qc,
  envmap_pars_vertex: eu,
  envmap_physical_pars_fragment: du,
  envmap_vertex: tu,
  fog_vertex: nu,
  fog_pars_vertex: iu,
  fog_fragment: ru,
  fog_pars_fragment: su,
  gradientmap_pars_fragment: au,
  lightmap_fragment: ou,
  lightmap_pars_fragment: lu,
  lights_lambert_fragment: cu,
  lights_lambert_pars_fragment: uu,
  lights_pars_begin: hu,
  lights_toon_fragment: fu,
  lights_toon_pars_fragment: pu,
  lights_phong_fragment: mu,
  lights_phong_pars_fragment: _u,
  lights_physical_fragment: gu,
  lights_physical_pars_fragment: vu,
  lights_fragment_begin: xu,
  lights_fragment_maps: Mu,
  lights_fragment_end: Su,
  logdepthbuf_fragment: Eu,
  logdepthbuf_pars_fragment: yu,
  logdepthbuf_pars_vertex: Tu,
  logdepthbuf_vertex: bu,
  map_fragment: Au,
  map_pars_fragment: wu,
  map_particle_fragment: Ru,
  map_particle_pars_fragment: Cu,
  metalnessmap_fragment: Lu,
  metalnessmap_pars_fragment: Pu,
  morphcolor_vertex: Du,
  morphnormal_vertex: Uu,
  morphtarget_pars_vertex: Iu,
  morphtarget_vertex: Nu,
  normal_fragment_begin: Fu,
  normal_fragment_maps: Ou,
  normal_pars_fragment: Bu,
  normal_pars_vertex: zu,
  normal_vertex: Gu,
  normalmap_pars_fragment: Hu,
  clearcoat_normal_fragment_begin: Vu,
  clearcoat_normal_fragment_maps: ku,
  clearcoat_pars_fragment: Wu,
  iridescence_pars_fragment: Xu,
  opaque_fragment: qu,
  packing: Yu,
  premultiplied_alpha_fragment: ju,
  project_vertex: Ku,
  dithering_fragment: Zu,
  dithering_pars_fragment: $u,
  roughnessmap_fragment: Ju,
  roughnessmap_pars_fragment: Qu,
  shadowmap_pars_fragment: eh,
  shadowmap_pars_vertex: th,
  shadowmap_vertex: nh,
  shadowmask_pars_fragment: ih,
  skinbase_vertex: rh,
  skinning_pars_vertex: sh,
  skinning_vertex: ah,
  skinnormal_vertex: oh,
  specularmap_fragment: lh,
  specularmap_pars_fragment: ch,
  tonemapping_fragment: uh,
  tonemapping_pars_fragment: hh,
  transmission_fragment: dh,
  transmission_pars_fragment: fh,
  uv_pars_fragment: ph,
  uv_pars_vertex: mh,
  uv_vertex: _h,
  worldpos_vertex: gh,
  background_vert: vh,
  background_frag: xh,
  backgroundCube_vert: Mh,
  backgroundCube_frag: Sh,
  cube_vert: Eh,
  cube_frag: yh,
  depth_vert: Th,
  depth_frag: bh,
  distanceRGBA_vert: Ah,
  distanceRGBA_frag: wh,
  equirect_vert: Rh,
  equirect_frag: Ch,
  linedashed_vert: Lh,
  linedashed_frag: Ph,
  meshbasic_vert: Dh,
  meshbasic_frag: Uh,
  meshlambert_vert: Ih,
  meshlambert_frag: Nh,
  meshmatcap_vert: Fh,
  meshmatcap_frag: Oh,
  meshnormal_vert: Bh,
  meshnormal_frag: zh,
  meshphong_vert: Gh,
  meshphong_frag: Hh,
  meshphysical_vert: Vh,
  meshphysical_frag: kh,
  meshtoon_vert: Wh,
  meshtoon_frag: Xh,
  points_vert: qh,
  points_frag: Yh,
  shadow_vert: jh,
  shadow_frag: Kh,
  sprite_vert: Zh,
  sprite_frag: $h
}, se = {
  common: {
    diffuse: { value: /* @__PURE__ */ new Xe(16777215) },
    opacity: { value: 1 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new Ve() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Ve() },
    alphaTest: { value: 0 }
  },
  specularmap: {
    specularMap: { value: null },
    specularMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  envmap: {
    envMap: { value: null },
    flipEnvMap: { value: -1 },
    reflectivity: { value: 1 },
    // basic, lambert, phong
    ior: { value: 1.5 },
    // physical
    refractionRatio: { value: 0.98 }
    // basic, lambert, phong
  },
  aomap: {
    aoMap: { value: null },
    aoMapIntensity: { value: 1 },
    aoMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  lightmap: {
    lightMap: { value: null },
    lightMapIntensity: { value: 1 },
    lightMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  bumpmap: {
    bumpMap: { value: null },
    bumpMapTransform: { value: /* @__PURE__ */ new Ve() },
    bumpScale: { value: 1 }
  },
  normalmap: {
    normalMap: { value: null },
    normalMapTransform: { value: /* @__PURE__ */ new Ve() },
    normalScale: { value: /* @__PURE__ */ new Ie(1, 1) }
  },
  displacementmap: {
    displacementMap: { value: null },
    displacementMapTransform: { value: /* @__PURE__ */ new Ve() },
    displacementScale: { value: 1 },
    displacementBias: { value: 0 }
  },
  emissivemap: {
    emissiveMap: { value: null },
    emissiveMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  metalnessmap: {
    metalnessMap: { value: null },
    metalnessMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  roughnessmap: {
    roughnessMap: { value: null },
    roughnessMapTransform: { value: /* @__PURE__ */ new Ve() }
  },
  gradientmap: {
    gradientMap: { value: null }
  },
  fog: {
    fogDensity: { value: 25e-5 },
    fogNear: { value: 1 },
    fogFar: { value: 2e3 },
    fogColor: { value: /* @__PURE__ */ new Xe(16777215) }
  },
  lights: {
    ambientLightColor: { value: [] },
    lightProbe: { value: [] },
    directionalLights: { value: [], properties: {
      direction: {},
      color: {}
    } },
    directionalLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    directionalShadowMap: { value: [] },
    directionalShadowMatrix: { value: [] },
    spotLights: { value: [], properties: {
      color: {},
      position: {},
      direction: {},
      distance: {},
      coneCos: {},
      penumbraCos: {},
      decay: {}
    } },
    spotLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {}
    } },
    spotLightMap: { value: [] },
    spotShadowMap: { value: [] },
    spotLightMatrix: { value: [] },
    pointLights: { value: [], properties: {
      color: {},
      position: {},
      decay: {},
      distance: {}
    } },
    pointLightShadows: { value: [], properties: {
      shadowBias: {},
      shadowNormalBias: {},
      shadowRadius: {},
      shadowMapSize: {},
      shadowCameraNear: {},
      shadowCameraFar: {}
    } },
    pointShadowMap: { value: [] },
    pointShadowMatrix: { value: [] },
    hemisphereLights: { value: [], properties: {
      direction: {},
      skyColor: {},
      groundColor: {}
    } },
    // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src
    rectAreaLights: { value: [], properties: {
      color: {},
      position: {},
      width: {},
      height: {}
    } },
    ltc_1: { value: null },
    ltc_2: { value: null }
  },
  points: {
    diffuse: { value: /* @__PURE__ */ new Xe(16777215) },
    opacity: { value: 1 },
    size: { value: 1 },
    scale: { value: 1 },
    map: { value: null },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Ve() },
    alphaTest: { value: 0 },
    uvTransform: { value: /* @__PURE__ */ new Ve() }
  },
  sprite: {
    diffuse: { value: /* @__PURE__ */ new Xe(16777215) },
    opacity: { value: 1 },
    center: { value: /* @__PURE__ */ new Ie(0.5, 0.5) },
    rotation: { value: 0 },
    map: { value: null },
    mapTransform: { value: /* @__PURE__ */ new Ve() },
    alphaMap: { value: null },
    alphaMapTransform: { value: /* @__PURE__ */ new Ve() },
    alphaTest: { value: 0 }
  }
}, Gt = {
  basic: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.specularmap,
      se.envmap,
      se.aomap,
      se.lightmap,
      se.fog
    ]),
    vertexShader: Be.meshbasic_vert,
    fragmentShader: Be.meshbasic_frag
  },
  lambert: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.specularmap,
      se.envmap,
      se.aomap,
      se.lightmap,
      se.emissivemap,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      se.fog,
      se.lights,
      {
        emissive: { value: /* @__PURE__ */ new Xe(0) }
      }
    ]),
    vertexShader: Be.meshlambert_vert,
    fragmentShader: Be.meshlambert_frag
  },
  phong: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.specularmap,
      se.envmap,
      se.aomap,
      se.lightmap,
      se.emissivemap,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      se.fog,
      se.lights,
      {
        emissive: { value: /* @__PURE__ */ new Xe(0) },
        specular: { value: /* @__PURE__ */ new Xe(1118481) },
        shininess: { value: 30 }
      }
    ]),
    vertexShader: Be.meshphong_vert,
    fragmentShader: Be.meshphong_frag
  },
  standard: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.envmap,
      se.aomap,
      se.lightmap,
      se.emissivemap,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      se.roughnessmap,
      se.metalnessmap,
      se.fog,
      se.lights,
      {
        emissive: { value: /* @__PURE__ */ new Xe(0) },
        roughness: { value: 1 },
        metalness: { value: 0 },
        envMapIntensity: { value: 1 }
        // temporary
      }
    ]),
    vertexShader: Be.meshphysical_vert,
    fragmentShader: Be.meshphysical_frag
  },
  toon: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.aomap,
      se.lightmap,
      se.emissivemap,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      se.gradientmap,
      se.fog,
      se.lights,
      {
        emissive: { value: /* @__PURE__ */ new Xe(0) }
      }
    ]),
    vertexShader: Be.meshtoon_vert,
    fragmentShader: Be.meshtoon_frag
  },
  matcap: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      se.fog,
      {
        matcap: { value: null }
      }
    ]),
    vertexShader: Be.meshmatcap_vert,
    fragmentShader: Be.meshmatcap_frag
  },
  points: {
    uniforms: /* @__PURE__ */ _t([
      se.points,
      se.fog
    ]),
    vertexShader: Be.points_vert,
    fragmentShader: Be.points_frag
  },
  dashed: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.fog,
      {
        scale: { value: 1 },
        dashSize: { value: 1 },
        totalSize: { value: 2 }
      }
    ]),
    vertexShader: Be.linedashed_vert,
    fragmentShader: Be.linedashed_frag
  },
  depth: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.displacementmap
    ]),
    vertexShader: Be.depth_vert,
    fragmentShader: Be.depth_frag
  },
  normal: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.bumpmap,
      se.normalmap,
      se.displacementmap,
      {
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Be.meshnormal_vert,
    fragmentShader: Be.meshnormal_frag
  },
  sprite: {
    uniforms: /* @__PURE__ */ _t([
      se.sprite,
      se.fog
    ]),
    vertexShader: Be.sprite_vert,
    fragmentShader: Be.sprite_frag
  },
  background: {
    uniforms: {
      uvTransform: { value: /* @__PURE__ */ new Ve() },
      t2D: { value: null },
      backgroundIntensity: { value: 1 }
    },
    vertexShader: Be.background_vert,
    fragmentShader: Be.background_frag
  },
  backgroundCube: {
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 },
      backgroundBlurriness: { value: 0 },
      backgroundIntensity: { value: 1 }
    },
    vertexShader: Be.backgroundCube_vert,
    fragmentShader: Be.backgroundCube_frag
  },
  cube: {
    uniforms: {
      tCube: { value: null },
      tFlip: { value: -1 },
      opacity: { value: 1 }
    },
    vertexShader: Be.cube_vert,
    fragmentShader: Be.cube_frag
  },
  equirect: {
    uniforms: {
      tEquirect: { value: null }
    },
    vertexShader: Be.equirect_vert,
    fragmentShader: Be.equirect_frag
  },
  distanceRGBA: {
    uniforms: /* @__PURE__ */ _t([
      se.common,
      se.displacementmap,
      {
        referencePosition: { value: /* @__PURE__ */ new P() },
        nearDistance: { value: 1 },
        farDistance: { value: 1e3 }
      }
    ]),
    vertexShader: Be.distanceRGBA_vert,
    fragmentShader: Be.distanceRGBA_frag
  },
  shadow: {
    uniforms: /* @__PURE__ */ _t([
      se.lights,
      se.fog,
      {
        color: { value: /* @__PURE__ */ new Xe(0) },
        opacity: { value: 1 }
      }
    ]),
    vertexShader: Be.shadow_vert,
    fragmentShader: Be.shadow_frag
  }
};
Gt.physical = {
  uniforms: /* @__PURE__ */ _t([
    Gt.standard.uniforms,
    {
      clearcoat: { value: 0 },
      clearcoatMap: { value: null },
      clearcoatMapTransform: { value: /* @__PURE__ */ new Ve() },
      clearcoatNormalMap: { value: null },
      clearcoatNormalMapTransform: { value: /* @__PURE__ */ new Ve() },
      clearcoatNormalScale: { value: /* @__PURE__ */ new Ie(1, 1) },
      clearcoatRoughness: { value: 0 },
      clearcoatRoughnessMap: { value: null },
      clearcoatRoughnessMapTransform: { value: /* @__PURE__ */ new Ve() },
      iridescence: { value: 0 },
      iridescenceMap: { value: null },
      iridescenceMapTransform: { value: /* @__PURE__ */ new Ve() },
      iridescenceIOR: { value: 1.3 },
      iridescenceThicknessMinimum: { value: 100 },
      iridescenceThicknessMaximum: { value: 400 },
      iridescenceThicknessMap: { value: null },
      iridescenceThicknessMapTransform: { value: /* @__PURE__ */ new Ve() },
      sheen: { value: 0 },
      sheenColor: { value: /* @__PURE__ */ new Xe(0) },
      sheenColorMap: { value: null },
      sheenColorMapTransform: { value: /* @__PURE__ */ new Ve() },
      sheenRoughness: { value: 1 },
      sheenRoughnessMap: { value: null },
      sheenRoughnessMapTransform: { value: /* @__PURE__ */ new Ve() },
      transmission: { value: 0 },
      transmissionMap: { value: null },
      transmissionMapTransform: { value: /* @__PURE__ */ new Ve() },
      transmissionSamplerSize: { value: /* @__PURE__ */ new Ie() },
      transmissionSamplerMap: { value: null },
      thickness: { value: 0 },
      thicknessMap: { value: null },
      thicknessMapTransform: { value: /* @__PURE__ */ new Ve() },
      attenuationDistance: { value: 0 },
      attenuationColor: { value: /* @__PURE__ */ new Xe(0) },
      specularColor: { value: /* @__PURE__ */ new Xe(1, 1, 1) },
      specularColorMap: { value: null },
      specularColorMapTransform: { value: /* @__PURE__ */ new Ve() },
      specularIntensity: { value: 1 },
      specularIntensityMap: { value: null },
      specularIntensityMapTransform: { value: /* @__PURE__ */ new Ve() },
      anisotropyVector: { value: /* @__PURE__ */ new Ie() },
      anisotropyMap: { value: null },
      anisotropyMapTransform: { value: /* @__PURE__ */ new Ve() }
    }
  ]),
  vertexShader: Be.meshphysical_vert,
  fragmentShader: Be.meshphysical_frag
};
const Wi = { r: 0, b: 0, g: 0 };
function Jh(i, e, t, n, r, s, o) {
  const a = new Xe(0);
  let l = s === !0 ? 0 : 1, c, h, d = null, p = 0, m = null;
  function g(f, u) {
    let b = !1, S = u.isScene === !0 ? u.background : null;
    S && S.isTexture && (S = (u.backgroundBlurriness > 0 ? t : e).get(S)), S === null ? v(a, l) : S && S.isColor && (v(S, 1), b = !0);
    const R = i.xr.getEnvironmentBlendMode();
    R === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, o) : R === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, o), (i.autoClear || b) && i.clear(i.autoClearColor, i.autoClearDepth, i.autoClearStencil), S && (S.isCubeTexture || S.mapping === rr) ? (h === void 0 && (h = new Ot(
      new ii(1, 1, 1),
      new wn({
        name: "BackgroundCubeMaterial",
        uniforms: ni(Gt.backgroundCube.uniforms),
        vertexShader: Gt.backgroundCube.vertexShader,
        fragmentShader: Gt.backgroundCube.fragmentShader,
        side: Mt,
        depthTest: !1,
        depthWrite: !1,
        fog: !1
      })
    ), h.geometry.deleteAttribute("normal"), h.geometry.deleteAttribute("uv"), h.onBeforeRender = function(D, C, A) {
      this.matrixWorld.copyPosition(A.matrixWorld);
    }, Object.defineProperty(h.material, "envMap", {
      get: function() {
        return this.uniforms.envMap.value;
      }
    }), r.update(h)), h.material.uniforms.envMap.value = S, h.material.uniforms.flipEnvMap.value = S.isCubeTexture && S.isRenderTargetTexture === !1 ? -1 : 1, h.material.uniforms.backgroundBlurriness.value = u.backgroundBlurriness, h.material.uniforms.backgroundIntensity.value = u.backgroundIntensity, h.material.toneMapped = Ke.getTransfer(S.colorSpace) !== Ze, (d !== S || p !== S.version || m !== i.toneMapping) && (h.material.needsUpdate = !0, d = S, p = S.version, m = i.toneMapping), h.layers.enableAll(), f.unshift(h, h.geometry, h.material, 0, 0, null)) : S && S.isTexture && (c === void 0 && (c = new Ot(
      new us(2, 2),
      new wn({
        name: "BackgroundMaterial",
        uniforms: ni(Gt.background.uniforms),
        vertexShader: Gt.background.vertexShader,
        fragmentShader: Gt.background.fragmentShader,
        side: un,
        depthTest: !1,
        depthWrite: !1,
        fog: !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 = S, c.material.uniforms.backgroundIntensity.value = u.backgroundIntensity, c.material.toneMapped = Ke.getTransfer(S.colorSpace) !== Ze, S.matrixAutoUpdate === !0 && S.updateMatrix(), c.material.uniforms.uvTransform.value.copy(S.matrix), (d !== S || p !== S.version || m !== i.toneMapping) && (c.material.needsUpdate = !0, d = S, p = S.version, m = i.toneMapping), c.layers.enableAll(), f.unshift(c, c.geometry, c.material, 0, 0, null));
  }
  function v(f, u) {
    f.getRGB(Wi, Co(i)), n.buffers.color.setClear(Wi.r, Wi.g, Wi.b, u, o);
  }
  return {
    getClearColor: function() {
      return a;
    },
    setClearColor: function(f, u = 1) {
      a.set(f), l = u, v(a, l);
    },
    getClearAlpha: function() {
      return l;
    },
    setClearAlpha: function(f) {
      l = f, v(a, l);
    },
    render: g
  };
}
function Qh(i, e, t, n) {
  const r = i.getParameter(i.MAX_VERTEX_ATTRIBS), s = n.isWebGL2 ? null : e.get("OES_vertex_array_object"), o = n.isWebGL2 || s !== null, a = {}, l = f(null);
  let c = l, h = !1;
  function d(L, F, V, Y, X) {
    let k = !1;
    if (o) {
      const q = v(Y, V, F);
      c !== q && (c = q, m(c.object)), k = u(L, Y, V, X), k && b(L, Y, V, X);
    } else {
      const q = F.wireframe === !0;
      (c.geometry !== Y.id || c.program !== V.id || c.wireframe !== q) && (c.geometry = Y.id, c.program = V.id, c.wireframe = q, k = !0);
    }
    X !== null && t.update(X, i.ELEMENT_ARRAY_BUFFER), (k || h) && (h = !1, W(L, F, V, Y), X !== null && i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, t.get(X).buffer));
  }
  function p() {
    return n.isWebGL2 ? i.createVertexArray() : s.createVertexArrayOES();
  }
  function m(L) {
    return n.isWebGL2 ? i.bindVertexArray(L) : s.bindVertexArrayOES(L);
  }
  function g(L) {
    return n.isWebGL2 ? i.deleteVertexArray(L) : s.deleteVertexArrayOES(L);
  }
  function v(L, F, V) {
    const Y = V.wireframe === !0;
    let X = a[L.id];
    X === void 0 && (X = {}, a[L.id] = X);
    let k = X[F.id];
    k === void 0 && (k = {}, X[F.id] = k);
    let q = k[Y];
    return q === void 0 && (q = f(p()), k[Y] = q), q;
  }
  function f(L) {
    const F = [], V = [], Y = [];
    for (let X = 0; X < r; X++)
      F[X] = 0, V[X] = 0, Y[X] = 0;
    return {
      // for backward compatibility on non-VAO support browser
      geometry: null,
      program: null,
      wireframe: !1,
      newAttributes: F,
      enabledAttributes: V,
      attributeDivisors: Y,
      object: L,
      attributes: {},
      index: null
    };
  }
  function u(L, F, V, Y) {
    const X = c.attributes, k = F.attributes;
    let q = 0;
    const Q = V.getAttributes();
    for (const ce in Q)
      if (Q[ce].location >= 0) {
        const j = X[ce];
        let oe = k[ce];
        if (oe === void 0 && (ce === "instanceMatrix" && L.instanceMatrix && (oe = L.instanceMatrix), ce === "instanceColor" && L.instanceColor && (oe = L.instanceColor)), j === void 0 || j.attribute !== oe || oe && j.data !== oe.data) return !0;
        q++;
      }
    return c.attributesNum !== q || c.index !== Y;
  }
  function b(L, F, V, Y) {
    const X = {}, k = F.attributes;
    let q = 0;
    const Q = V.getAttributes();
    for (const ce in Q)
      if (Q[ce].location >= 0) {
        let j = k[ce];
        j === void 0 && (ce === "instanceMatrix" && L.instanceMatrix && (j = L.instanceMatrix), ce === "instanceColor" && L.instanceColor && (j = L.instanceColor));
        const oe = {};
        oe.attribute = j, j && j.data && (oe.data = j.data), X[ce] = oe, q++;
      }
    c.attributes = X, c.attributesNum = q, c.index = Y;
  }
  function S() {
    const L = c.newAttributes;
    for (let F = 0, V = L.length; F < V; F++)
      L[F] = 0;
  }
  function R(L) {
    D(L, 0);
  }
  function D(L, F) {
    const V = c.newAttributes, Y = c.enabledAttributes, X = c.attributeDivisors;
    V[L] = 1, Y[L] === 0 && (i.enableVertexAttribArray(L), Y[L] = 1), X[L] !== F && ((n.isWebGL2 ? i : e.get("ANGLE_instanced_arrays"))[n.isWebGL2 ? "vertexAttribDivisor" : "vertexAttribDivisorANGLE"](L, F), X[L] = F);
  }
  function C() {
    const L = c.newAttributes, F = c.enabledAttributes;
    for (let V = 0, Y = F.length; V < Y; V++)
      F[V] !== L[V] && (i.disableVertexAttribArray(V), F[V] = 0);
  }
  function A(L, F, V, Y, X, k, q) {
    q === !0 ? i.vertexAttribIPointer(L, F, V, X, k) : i.vertexAttribPointer(L, F, V, Y, X, k);
  }
  function W(L, F, V, Y) {
    if (n.isWebGL2 === !1 && (L.isInstancedMesh || Y.isInstancedBufferGeometry) && e.get("ANGLE_instanced_arrays") === null)
      return;
    S();
    const X = Y.attributes, k = V.getAttributes(), q = F.defaultAttributeValues;
    for (const Q in k) {
      const ce = k[Q];
      if (ce.location >= 0) {
        let H = X[Q];
        if (H === void 0 && (Q === "instanceMatrix" && L.instanceMatrix && (H = L.instanceMatrix), Q === "instanceColor" && L.instanceColor && (H = L.instanceColor)), H !== void 0) {
          const j = H.normalized, oe = H.itemSize, ve = t.get(H);
          if (ve === void 0) continue;
          const _e = ve.buffer, we = ve.type, Ae = ve.bytesPerElement, ge = n.isWebGL2 === !0 && (we === i.INT || we === i.UNSIGNED_INT || H.gpuType === co);
          if (H.isInterleavedBufferAttribute) {
            const Pe = H.data, N = Pe.stride, rt = H.offset;
            if (Pe.isInstancedInterleavedBuffer) {
              for (let Me = 0; Me < ce.locationSize; Me++)
                D(ce.location + Me, Pe.meshPerAttribute);
              L.isInstancedMesh !== !0 && Y._maxInstanceCount === void 0 && (Y._maxInstanceCount = Pe.meshPerAttribute * Pe.count);
            } else
              for (let Me = 0; Me < ce.locationSize; Me++)
                R(ce.location + Me);
            i.bindBuffer(i.ARRAY_BUFFER, _e);
            for (let Me = 0; Me < ce.locationSize; Me++)
              A(
                ce.location + Me,
                oe / ce.locationSize,
                we,
                j,
                N * Ae,
                (rt + oe / ce.locationSize * Me) * Ae,
                ge
              );
          } else {
            if (H.isInstancedBufferAttribute) {
              for (let Pe = 0; Pe < ce.locationSize; Pe++)
                D(ce.location + Pe, H.meshPerAttribute);
              L.isInstancedMesh !== !0 && Y._maxInstanceCount === void 0 && (Y._maxInstanceCount = H.meshPerAttribute * H.count);
            } else
              for (let Pe = 0; Pe < ce.locationSize; Pe++)
                R(ce.location + Pe);
            i.bindBuffer(i.ARRAY_BUFFER, _e);
            for (let Pe = 0; Pe < ce.locationSize; Pe++)
              A(
                ce.location + Pe,
                oe / ce.locationSize,
                we,
                j,
                oe * Ae,
                oe / ce.locationSize * Pe * Ae,
                ge
              );
          }
        } else if (q !== void 0) {
          const j = q[Q];
          if (j !== void 0)
            switch (j.length) {
              case 2:
                i.vertexAttrib2fv(ce.location, j);
                break;
              case 3:
                i.vertexAttrib3fv(ce.location, j);
                break;
              case 4:
                i.vertexAttrib4fv(ce.location, j);
                break;
              default:
                i.vertexAttrib1fv(ce.location, j);
            }
        }
      }
    }
    C();
  }
  function x() {
    Z();
    for (const L in a) {
      const F = a[L];
      for (const V in F) {
        const Y = F[V];
        for (const X in Y)
          g(Y[X].object), delete Y[X];
        delete F[V];
      }
      delete a[L];
    }
  }
  function y(L) {
    if (a[L.id] === void 0) return;
    const F = a[L.id];
    for (const V in F) {
      const Y = F[V];
      for (const X in Y)
        g(Y[X].object), delete Y[X];
      delete F[V];
    }
    delete a[L.id];
  }
  function z(L) {
    for (const F in a) {
      const V = a[F];
      if (V[L.id] === void 0) continue;
      const Y = V[L.id];
      for (const X in Y)
        g(Y[X].object), delete Y[X];
      delete V[L.id];
    }
  }
  function Z() {
    re(), h = !0, c !== l && (c = l, m(c.object));
  }
  function re() {
    l.geometry = null, l.program = null, l.wireframe = !1;
  }
  return {
    setup: d,
    reset: Z,
    resetDefaultState: re,
    dispose: x,
    releaseStatesOfGeometry: y,
    releaseStatesOfProgram: z,
    initAttributes: S,
    enableAttribute: R,
    disableUnusedAttributes: C
  };
}
function ed(i, e, t, n) {
  const r = n.isWebGL2;
  let s;
  function o(h) {
    s = h;
  }
  function a(h, d) {
    i.drawArrays(s, h, d), t.update(d, s, 1);
  }
  function l(h, d, p) {
    if (p === 0) return;
    let m, g;
    if (r)
      m = i, g = "drawArraysInstanced";
    else if (m = e.get("ANGLE_instanced_arrays"), g = "drawArraysInstancedANGLE", m === null) {
      console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
      return;
    }
    m[g](s, h, d, p), t.update(d, s, p);
  }
  function c(h, d, p) {
    if (p === 0) return;
    const m = e.get("WEBGL_multi_draw");
    if (m === null)
      for (let g = 0; g < p; g++)
        this.render(h[g], d[g]);
    else {
      m.multiDrawArraysWEBGL(s, h, 0, d, 0, p);
      let g = 0;
      for (let v = 0; v < p; v++)
        g += d[v];
      t.update(g, s, 1);
    }
  }
  this.setMode = o, this.render = a, this.renderInstances = l, this.renderMultiDraw = c;
}
function td(i, e, t) {
  let n;
  function r() {
    if (n !== void 0) return n;
    if (e.has("EXT_texture_filter_anisotropic") === !0) {
      const A = e.get("EXT_texture_filter_anisotropic");
      n = i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
    } else
      n = 0;
    return n;
  }
  function s(A) {
    if (A === "highp") {
      if (i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.HIGH_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.HIGH_FLOAT).precision > 0)
        return "highp";
      A = "mediump";
    }
    return A === "mediump" && i.getShaderPrecisionFormat(i.VERTEX_SHADER, i.MEDIUM_FLOAT).precision > 0 && i.getShaderPrecisionFormat(i.FRAGMENT_SHADER, i.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp";
  }
  const o = typeof WebGL2RenderingContext < "u" && i.constructor.name === "WebGL2RenderingContext";
  let a = t.precision !== void 0 ? t.precision : "highp";
  const l = s(a);
  l !== a && (console.warn("THREE.WebGLRenderer:", a, "not supported, using", l, "instead."), a = l);
  const c = o || e.has("WEBGL_draw_buffers"), h = t.logarithmicDepthBuffer === !0, d = i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS), p = i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS), m = i.getParameter(i.MAX_TEXTURE_SIZE), g = i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE), v = i.getParameter(i.MAX_VERTEX_ATTRIBS), f = i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS), u = i.getParameter(i.MAX_VARYING_VECTORS), b = i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS), S = p > 0, R = o || e.has("OES_texture_float"), D = S && R, C = o ? i.getParameter(i.MAX_SAMPLES) : 0;
  return {
    isWebGL2: o,
    drawBuffers: c,
    getMaxAnisotropy: r,
    getMaxPrecision: s,
    precision: a,
    logarithmicDepthBuffer: h,
    maxTextures: d,
    maxVertexTextures: p,
    maxTextureSize: m,
    maxCubemapSize: g,
    maxAttributes: v,
    maxVertexUniforms: f,
    maxVaryings: u,
    maxFragmentUniforms: b,
    vertexTextures: S,
    floatFragmentTextures: R,
    floatVertexTextures: D,
    maxSamples: C
  };
}
function nd(i) {
  const e = this;
  let t = null, n = 0, r = !1, s = !1;
  const o = new rn(), a = new Ve(), l = { value: null, needsUpdate: !1 };
  this.uniform = l, this.numPlanes = 0, this.numIntersection = 0, this.init = function(d, p) {
    const m = d.length !== 0 || p || // enable state of previous frame - the clipping code has to
    // run another frame in order to reset the state:
    n !== 0 || r;
    return r = p, n = d.length, m;
  }, this.beginShadows = function() {
    s = !0, h(null);
  }, this.endShadows = function() {
    s = !1;
  }, this.setGlobalState = function(d, p) {
    t = h(d, p, 0);
  }, this.setState = function(d, p, m) {
    const g = d.clippingPlanes, v = d.clipIntersection, f = d.clipShadows, u = i.get(d);
    if (!r || g === null || g.length === 0 || s && !f)
      s ? h(null) : c();
    else {
      const b = s ? 0 : n, S = b * 4;
      let R = u.clippingState || null;
      l.value = R, R = h(g, p, S, m);
      for (let D = 0; D !== S; ++D)
        R[D] = t[D];
      u.clippingState = R, this.numIntersection = v ? this.numPlanes : 0, this.numPlanes += b;
    }
  };
  function c() {
    l.value !== t && (l.value = t, l.needsUpdate = n > 0), e.numPlanes = n, e.numIntersection = 0;
  }
  function h(d, p, m, g) {
    const v = d !== null ? d.length : 0;
    let f = null;
    if (v !== 0) {
      if (f = l.value, g !== !0 || f === null) {
        const u = m + v * 4, b = p.matrixWorldInverse;
        a.getNormalMatrix(b), (f === null || f.length < u) && (f = new Float32Array(u));
        for (let S = 0, R = m; S !== v; ++S, R += 4)
          o.copy(d[S]).applyMatrix4(b, a), o.normal.toArray(f, R), f[R + 3] = o.constant;
      }
      l.value = f, l.needsUpdate = !0;
    }
    return e.numPlanes = v, e.numIntersection = 0, f;
  }
}
function id(i) {
  let e = /* @__PURE__ */ new WeakMap();
  function t(o, a) {
    return a === $r ? o.mapping = Qn : a === Jr && (o.mapping = ei), o;
  }
  function n(o) {
    if (o && o.isTexture) {
      const a = o.mapping;
      if (a === $r || a === Jr)
        if (e.has(o)) {
          const l = e.get(o).texture;
          return t(l, o.mapping);
        } else {
          const l = o.image;
          if (l && l.height > 0) {
            const c = new mc(l.height / 2);
            return c.fromEquirectangularTexture(i, o), e.set(o, c), o.addEventListener("dispose", r), t(c.texture, o.mapping);
          } else
            return null;
        }
    }
    return o;
  }
  function r(o) {
    const a = o.target;
    a.removeEventListener("dispose", r);
    const l = e.get(a);
    l !== void 0 && (e.delete(a), l.dispose());
  }
  function s() {
    e = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: n,
    dispose: s
  };
}
class Uo extends Lo {
  constructor(e = -1, t = 1, n = 1, r = -1, s = 0.1, o = 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 = s, this.far = o, 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, s, o) {
    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 = s, this.view.height = o, this.updateProjectionMatrix();
  }
  clearViewOffset() {
    this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix();
  }
  updateProjectionMatrix() {
    const 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;
    let s = n - e, o = n + e, a = r + t, l = r - t;
    if (this.view !== null && this.view.enabled) {
      const c = (this.right - this.left) / this.view.fullWidth / this.zoom, h = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
      s += c * this.view.offsetX, o = s + c * this.view.width, a -= h * this.view.offsetY, l = a - h * this.view.height;
    }
    this.projectionMatrix.makeOrthographic(s, o, a, l, this.near, this.far, this.coordinateSystem), this.projectionMatrixInverse.copy(this.projectionMatrix).invert();
  }
  toJSON(e) {
    const 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;
  }
}
const Kn = 4, xa = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582], Sn = 20, Br = /* @__PURE__ */ new Uo(), Ma = /* @__PURE__ */ new Xe();
let zr = null, Gr = 0, Hr = 0;
const xn = (1 + Math.sqrt(5)) / 2, Yn = 1 / xn, Sa = [
  /* @__PURE__ */ new P(1, 1, 1),
  /* @__PURE__ */ new P(-1, 1, 1),
  /* @__PURE__ */ new P(1, 1, -1),
  /* @__PURE__ */ new P(-1, 1, -1),
  /* @__PURE__ */ new P(0, xn, Yn),
  /* @__PURE__ */ new P(0, xn, -Yn),
  /* @__PURE__ */ new P(Yn, 0, xn),
  /* @__PURE__ */ new P(-Yn, 0, xn),
  /* @__PURE__ */ new P(xn, Yn, 0),
  /* @__PURE__ */ new P(-xn, Yn, 0)
];
class Ea {
  constructor(e) {
    this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._lodPlanes = [], this._sizeLods = [], this._sigmas = [], this._blurMaterial = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._compileMaterial(this._blurMaterial);
  }
  /**
   * Generates a PMREM from a supplied Scene, which can be faster than using an
   * image if networking bandwidth is low. Optional sigma specifies a blur radius
   * in radians to be applied to the scene before PMREM generation. Optional near
   * and far planes ensure the scene is rendered in its entirety (the cubeCamera
   * is placed at the origin).
   */
  fromScene(e, t = 0, n = 0.1, r = 100) {
    zr = this._renderer.getRenderTarget(), Gr = this._renderer.getActiveCubeFace(), Hr = this._renderer.getActiveMipmapLevel(), this._setSize(256);
    const s = this._allocateTargets();
    return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s;
  }
  /**
   * Generates a PMREM from an equirectangular texture, which can be either LDR
   * or HDR. The ideal input image size is 1k (1024 x 512),
   * as this matches best with the 256 x 256 cubemap output.
   */
  fromEquirectangular(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Generates a PMREM from an cubemap texture, which can be either LDR
   * or HDR. The ideal input cube size is 256 x 256,
   * as this matches best with the 256 x 256 cubemap output.
   */
  fromCubemap(e, t = null) {
    return this._fromTexture(e, t);
  }
  /**
   * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileCubemapShader() {
    this._cubemapMaterial === null && (this._cubemapMaterial = ba(), this._compileMaterial(this._cubemapMaterial));
  }
  /**
   * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during
   * your texture's network fetch for increased concurrency.
   */
  compileEquirectangularShader() {
    this._equirectMaterial === null && (this._equirectMaterial = Ta(), this._compileMaterial(this._equirectMaterial));
  }
  /**
   * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,
   * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on
   * one of them will cause any others to also become unusable.
   */
  dispose() {
    this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose();
  }
  // private interface
  _setSize(e) {
    this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = Math.pow(2, this._lodMax);
  }
  _dispose() {
    this._blurMaterial !== null && this._blurMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose();
    for (let e = 0; e < this._lodPlanes.length; e++)
      this._lodPlanes[e].dispose();
  }
  _cleanup(e) {
    this._renderer.setRenderTarget(zr, Gr, Hr), e.scissorTest = !1, Xi(e, 0, 0, e.width, e.height);
  }
  _fromTexture(e, t) {
    e.mapping === Qn || e.mapping === ei ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), zr = this._renderer.getRenderTarget(), Gr = this._renderer.getActiveCubeFace(), Hr = this._renderer.getActiveMipmapLevel();
    const n = t || this._allocateTargets();
    return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n;
  }
  _allocateTargets() {
    const e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = {
      magFilter: Rt,
      minFilter: Rt,
      generateMipmaps: !1,
      type: gi,
      format: Ft,
      colorSpace: $t,
      depthBuffer: !1
    }, r = ya(e, t, n);
    if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) {
      this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = ya(e, t, n);
      const { _lodMax: s } = this;
      ({ sizeLods: this._sizeLods, lodPlanes: this._lodPlanes, sigmas: this._sigmas } = rd(s)), this._blurMaterial = sd(s, e, t);
    }
    return r;
  }
  _compileMaterial(e) {
    const t = new Ot(this._lodPlanes[0], e);
    this._renderer.compile(t, Br);
  }
  _sceneToCubeUV(e, t, n, r) {
    const a = new Tt(90, 1, t, n), l = [1, -1, 1, 1, 1, 1], c = [1, 1, 1, -1, -1, -1], h = this._renderer, d = h.autoClear, p = h.toneMapping;
    h.getClearColor(Ma), h.toneMapping = ln, h.autoClear = !1;
    const m = new ls({
      name: "PMREM.Background",
      side: Mt,
      depthWrite: !1,
      depthTest: !1
    }), g = new Ot(new ii(), m);
    let v = !1;
    const f = e.background;
    f ? f.isColor && (m.color.copy(f), e.background = null, v = !0) : (m.color.copy(Ma), v = !0);
    for (let u = 0; u < 6; u++) {
      const b = u % 3;
      b === 0 ? (a.up.set(0, l[u], 0), a.lookAt(c[u], 0, 0)) : b === 1 ? (a.up.set(0, 0, l[u]), a.lookAt(0, c[u], 0)) : (a.up.set(0, l[u], 0), a.lookAt(0, 0, c[u]));
      const S = this._cubeSize;
      Xi(r, b * S, u > 2 ? S : 0, S, S), h.setRenderTarget(r), v && h.render(g, a), h.render(e, a);
    }
    g.geometry.dispose(), g.material.dispose(), h.toneMapping = p, h.autoClear = d, e.background = f;
  }
  _textureToCubeUV(e, t) {
    const n = this._renderer, r = e.mapping === Qn || e.mapping === ei;
    r ? (this._cubemapMaterial === null && (this._cubemapMaterial = ba()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = Ta());
    const s = r ? this._cubemapMaterial : this._equirectMaterial, o = new Ot(this._lodPlanes[0], s), a = s.uniforms;
    a.envMap.value = e;
    const l = this._cubeSize;
    Xi(t, 0, 0, 3 * l, 2 * l), n.setRenderTarget(t), n.render(o, Br);
  }
  _applyPMREM(e) {
    const t = this._renderer, n = t.autoClear;
    t.autoClear = !1;
    for (let r = 1; r < this._lodPlanes.length; r++) {
      const s = Math.sqrt(this._sigmas[r] * this._sigmas[r] - this._sigmas[r - 1] * this._sigmas[r - 1]), o = Sa[(r - 1) % Sa.length];
      this._blur(e, r - 1, r, s, o);
    }
    t.autoClear = n;
  }
  /**
   * This is a two-pass Gaussian blur for a cubemap. Normally this is done
   * vertically and horizontally, but this breaks down on a cube. Here we apply
   * the blur latitudinally (around the poles), and then longitudinally (towards
   * the poles) to approximate the orthogonally-separable blur. It is least
   * accurate at the poles, but still does a decent job.
   */
  _blur(e, t, n, r, s) {
    const o = this._pingPongRenderTarget;
    this._halfBlur(
      e,
      o,
      t,
      n,
      r,
      "latitudinal",
      s
    ), this._halfBlur(
      o,
      e,
      n,
      n,
      r,
      "longitudinal",
      s
    );
  }
  _halfBlur(e, t, n, r, s, o, a) {
    const l = this._renderer, c = this._blurMaterial;
    o !== "latitudinal" && o !== "longitudinal" && console.error(
      "blur direction must be either latitudinal or longitudinal!"
    );
    const h = 3, d = new Ot(this._lodPlanes[r], c), p = c.uniforms, m = this._sizeLods[n] - 1, g = isFinite(s) ? Math.PI / (2 * m) : 2 * Math.PI / (2 * Sn - 1), v = s / g, f = isFinite(s) ? 1 + Math.floor(h * v) : Sn;
    f > Sn && console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${Sn}`);
    const u = [];
    let b = 0;
    for (let A = 0; A < Sn; ++A) {
      const W = A / v, x = Math.exp(-W * W / 2);
      u.push(x), A === 0 ? b += x : A < f && (b += 2 * x);
    }
    for (let A = 0; A < u.length; A++)
      u[A] = u[A] / b;
    p.envMap.value = e.texture, p.samples.value = f, p.weights.value = u, p.latitudinal.value = o === "latitudinal", a && (p.poleAxis.value = a);
    const { _lodMax: S } = this;
    p.dTheta.value = g, p.mipInt.value = S - n;
    const R = this._sizeLods[r], D = 3 * R * (r > S - Kn ? r - S + Kn : 0), C = 4 * (this._cubeSize - R);
    Xi(t, D, C, 3 * R, 2 * R), l.setRenderTarget(t), l.render(d, Br);
  }
}
function rd(i) {
  const e = [], t = [], n = [];
  let r = i;
  const s = i - Kn + 1 + xa.length;
  for (let o = 0; o < s; o++) {
    const a = Math.pow(2, r);
    t.push(a);
    let l = 1 / a;
    o > i - Kn ? l = xa[o - i + Kn - 1] : o === 0 && (l = 0), n.push(l);
    const c = 1 / (a - 2), h = -c, d = 1 + c, p = [h, h, d, h, d, d, h, h, d, d, h, d], m = 6, g = 6, v = 3, f = 2, u = 1, b = new Float32Array(v * g * m), S = new Float32Array(f * g * m), R = new Float32Array(u * g * m);
    for (let C = 0; C < m; C++) {
      const A = C % 3 * 2 / 3 - 1, W = C > 2 ? 0 : -1, x = [
        A,
        W,
        0,
        A + 2 / 3,
        W,
        0,
        A + 2 / 3,
        W + 1,
        0,
        A,
        W,
        0,
        A + 2 / 3,
        W + 1,
        0,
        A,
        W + 1,
        0
      ];
      b.set(x, v * g * C), S.set(p, f * g * C);
      const y = [C, C, C, C, C, C];
      R.set(y, u * g * C);
    }
    const D = new hn();
    D.setAttribute("position", new Bt(b, v)), D.setAttribute("uv", new Bt(S, f)), D.setAttribute("faceIndex", new Bt(R, u)), e.push(D), r > Kn && r--;
  }
  return { lodPlanes: e, sizeLods: t, sigmas: n };
}
function ya(i, e, t) {
  const n = new bn(i, e, t);
  return n.texture.mapping = rr, n.texture.name = "PMREM.cubeUv", n.scissorTest = !0, n;
}
function Xi(i, e, t, n, r) {
  i.viewport.set(e, t, n, r), i.scissor.set(e, t, n, r);
}
function sd(i, e, t) {
  const n = new Float32Array(Sn), r = new P(0, 1, 0);
  return new wn({
    name: "SphericalGaussianBlur",
    defines: {
      n: Sn,
      CUBEUV_TEXEL_WIDTH: 1 / e,
      CUBEUV_TEXEL_HEIGHT: 1 / t,
      CUBEUV_MAX_MIP: `${i}.0`
    },
    uniforms: {
      envMap: { value: null },
      samples: { value: 1 },
      weights: { value: n },
      latitudinal: { value: !1 },
      dTheta: { value: 0 },
      mipInt: { value: 0 },
      poleAxis: { value: r }
    },
    vertexShader: hs(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`
    ),
    blending: on,
    depthTest: !1,
    depthWrite: !1
  });
}
function Ta() {
  return new wn({
    name: "EquirectangularToCubeUV",
    uniforms: {
      envMap: { value: null }
    },
    vertexShader: hs(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`
    ),
    blending: on,
    depthTest: !1,
    depthWrite: !1
  });
}
function ba() {
  return new wn({
    name: "CubemapToCubeUV",
    uniforms: {
      envMap: { value: null },
      flipEnvMap: { value: -1 }
    },
    vertexShader: hs(),
    fragmentShader: (
      /* glsl */
      `

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`
    ),
    blending: on,
    depthTest: !1,
    depthWrite: !1
  });
}
function hs() {
  return (
    /* glsl */
    `

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`
  );
}
function ad(i) {
  let e = /* @__PURE__ */ new WeakMap(), t = null;
  function n(a) {
    if (a && a.isTexture) {
      const l = a.mapping, c = l === $r || l === Jr, h = l === Qn || l === ei;
      if (c || h)
        if (a.isRenderTargetTexture && a.needsPMREMUpdate === !0) {
          a.needsPMREMUpdate = !1;
          let d = e.get(a);
          return t === null && (t = new Ea(i)), d = c ? t.fromEquirectangular(a, d) : t.fromCubemap(a, d), e.set(a, d), d.texture;
        } else {
          if (e.has(a))
            return e.get(a).texture;
          {
            const d = a.image;
            if (c && d && d.height > 0 || h && d && r(d)) {
              t === null && (t = new Ea(i));
              const p = c ? t.fromEquirectangular(a) : t.fromCubemap(a);
              return e.set(a, p), a.addEventListener("dispose", s), p.texture;
            } else
              return null;
          }
        }
    }
    return a;
  }
  function r(a) {
    let l = 0;
    const c = 6;
    for (let h = 0; h < c; h++)
      a[h] !== void 0 && l++;
    return l === c;
  }
  function s(a) {
    const l = a.target;
    l.removeEventListener("dispose", s);
    const c = e.get(l);
    c !== void 0 && (e.delete(l), c.dispose());
  }
  function o() {
    e = /* @__PURE__ */ new WeakMap(), t !== null && (t.dispose(), t = null);
  }
  return {
    get: n,
    dispose: o
  };
}
function od(i) {
  const e = {};
  function t(n) {
    if (e[n] !== void 0)
      return e[n];
    let r;
    switch (n) {
      case "WEBGL_depth_texture":
        r = i.getExtension("WEBGL_depth_texture") || i.getExtension("MOZ_WEBGL_depth_texture") || i.getExtension("WEBKIT_WEBGL_depth_texture");
        break;
      case "EXT_texture_filter_anisotropic":
        r = i.getExtension("EXT_texture_filter_anisotropic") || i.getExtension("MOZ_EXT_texture_filter_anisotropic") || i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
        break;
      case "WEBGL_compressed_texture_s3tc":
        r = i.getExtension("WEBGL_compressed_texture_s3tc") || i.getExtension("MOZ_WEBGL_compressed_texture_s3tc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
        break;
      case "WEBGL_compressed_texture_pvrtc":
        r = i.getExtension("WEBGL_compressed_texture_pvrtc") || i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");
        break;
      default:
        r = i.getExtension(n);
    }
    return e[n] = r, r;
  }
  return {
    has: function(n) {
      return t(n) !== null;
    },
    init: function(n) {
      n.isWebGL2 ? (t("EXT_color_buffer_float"), t("WEBGL_clip_cull_distance")) : (t("WEBGL_depth_texture"), t("OES_texture_float"), t("OES_texture_half_float"), t("OES_texture_half_float_linear"), t("OES_standard_derivatives"), t("OES_element_index_uint"), t("OES_vertex_array_object"), t("ANGLE_instanced_arrays")), t("OES_texture_float_linear"), t("EXT_color_buffer_half_float"), t("WEBGL_multisampled_render_to_texture");
    },
    get: function(n) {
      const r = t(n);
      return r === null && console.warn("THREE.WebGLRenderer: " + n + " extension not supported."), r;
    }
  };
}
function ld(i, e, t, n) {
  const r = {}, s = /* @__PURE__ */ new WeakMap();
  function o(d) {
    const p = d.target;
    p.index !== null && e.remove(p.index);
    for (const g in p.attributes)
      e.remove(p.attributes[g]);
    for (const g in p.morphAttributes) {
      const v = p.morphAttributes[g];
      for (let f = 0, u = v.length; f < u; f++)
        e.remove(v[f]);
    }
    p.removeEventListener("dispose", o), delete r[p.id];
    const m = s.get(p);
    m && (e.remove(m), s.delete(p)), n.releaseStatesOfGeometry(p), p.isInstancedBufferGeometry === !0 && delete p._maxInstanceCount, t.memory.geometries--;
  }
  function a(d, p) {
    return r[p.id] === !0 || (p.addEventListener("dispose", o), r[p.id] = !0, t.memory.geometries++), p;
  }
  function l(d) {
    const p = d.attributes;
    for (const g in p)
      e.update(p[g], i.ARRAY_BUFFER);
    const m = d.morphAttributes;
    for (const g in m) {
      const v = m[g];
      for (let f = 0, u = v.length; f < u; f++)
        e.update(v[f], i.ARRAY_BUFFER);
    }
  }
  function c(d) {
    const p = [], m = d.index, g = d.attributes.position;
    let v = 0;
    if (m !== null) {
      const b = m.array;
      v = m.version;
      for (let S = 0, R = b.length; S < R; S += 3) {
        const D = b[S + 0], C = b[S + 1], A = b[S + 2];
        p.push(D, C, C, A, A, D);
      }
    } else if (g !== void 0) {
      const b = g.array;
      v = g.version;
      for (let S = 0, R = b.length / 3 - 1; S < R; S += 3) {
        const D = S + 0, C = S + 1, A = S + 2;
        p.push(D, C, C, A, A, D);
      }
    } else
      return;
    const f = new (Mo(p) ? Ro : wo)(p, 1);
    f.version = v;
    const u = s.get(d);
    u && e.remove(u), s.set(d, f);
  }
  function h(d) {
    const p = s.get(d);
    if (p) {
      const m = d.index;
      m !== null && p.version < m.version && c(d);
    } else
      c(d);
    return s.get(d);
  }
  return {
    get: a,
    update: l,
    getWireframeAttribute: h
  };
}
function cd(i, e, t, n) {
  const r = n.isWebGL2;
  let s;
  function o(m) {
    s = m;
  }
  let a, l;
  function c(m) {
    a = m.type, l = m.bytesPerElement;
  }
  function h(m, g) {
    i.drawElements(s, g, a, m * l), t.update(g, s, 1);
  }
  function d(m, g, v) {
    if (v === 0) return;
    let f, u;
    if (r)
      f = i, u = "drawElementsInstanced";
    else if (f = e.get("ANGLE_instanced_arrays"), u = "drawElementsInstancedANGLE", f === null) {
      console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
      return;
    }
    f[u](s, g, a, m * l, v), t.update(g, s, v);
  }
  function p(m, g, v) {
    if (v === 0) return;
    const f = e.get("WEBGL_multi_draw");
    if (f === null)
      for (let u = 0; u < v; u++)
        this.render(m[u] / l, g[u]);
    else {
      f.multiDrawElementsWEBGL(s, g, 0, a, m, 0, v);
      let u = 0;
      for (let b = 0; b < v; b++)
        u += g[b];
      t.update(u, s, 1);
    }
  }
  this.setMode = o, this.setIndex = c, this.render = h, this.renderInstances = d, this.renderMultiDraw = p;
}
function ud(i) {
  const e = {
    geometries: 0,
    textures: 0
  }, t = {
    frame: 0,
    calls: 0,
    triangles: 0,
    points: 0,
    lines: 0
  };
  function n(s, o, a) {
    switch (t.calls++, o) {
      case i.TRIANGLES:
        t.triangles += a * (s / 3);
        break;
      case i.LINES:
        t.lines += a * (s / 2);
        break;
      case i.LINE_STRIP:
        t.lines += a * (s - 1);
        break;
      case i.LINE_LOOP:
        t.lines += a * s;
        break;
      case i.POINTS:
        t.points += a * s;
        break;
      default:
        console.error("THREE.WebGLInfo: Unknown draw mode:", o);
        break;
    }
  }
  function r() {
    t.calls = 0, t.triangles = 0, t.points = 0, t.lines = 0;
  }
  return {
    memory: e,
    render: t,
    programs: null,
    autoReset: !0,
    reset: r,
    update: n
  };
}
function hd(i, e) {
  return i[0] - e[0];
}
function dd(i, e) {
  return Math.abs(e[1]) - Math.abs(i[1]);
}
function fd(i, e, t) {
  const n = {}, r = new Float32Array(8), s = /* @__PURE__ */ new WeakMap(), o = new $e(), a = [];
  for (let c = 0; c < 8; c++)
    a[c] = [c, 0];
  function l(c, h, d) {
    const p = c.morphTargetInfluences;
    if (e.isWebGL2 === !0) {
      const m = h.morphAttributes.position || h.morphAttributes.normal || h.morphAttributes.color, g = m !== void 0 ? m.length : 0;
      let v = s.get(h);
      if (v === void 0 || v.count !== g) {
        let L = function() {
          Z.dispose(), s.delete(h), h.removeEventListener("dispose", L);
        };
        v !== void 0 && v.texture.dispose();
        const b = h.morphAttributes.position !== void 0, S = h.morphAttributes.normal !== void 0, R = h.morphAttributes.color !== void 0, D = h.morphAttributes.position || [], C = h.morphAttributes.normal || [], A = h.morphAttributes.color || [];
        let W = 0;
        b === !0 && (W = 1), S === !0 && (W = 2), R === !0 && (W = 3);
        let x = h.attributes.position.count * W, y = 1;
        x > e.maxTextureSize && (y = Math.ceil(x / e.maxTextureSize), x = e.maxTextureSize);
        const z = new Float32Array(x * y * 4 * g), Z = new yo(z, x, y, g);
        Z.type = an, Z.needsUpdate = !0;
        const re = W * 4;
        for (let F = 0; F < g; F++) {
          const V = D[F], Y = C[F], X = A[F], k = x * y * 4 * F;
          for (let q = 0; q < V.count; q++) {
            const Q = q * re;
            b === !0 && (o.fromBufferAttribute(V, q), z[k + Q + 0] = o.x, z[k + Q + 1] = o.y, z[k + Q + 2] = o.z, z[k + Q + 3] = 0), S === !0 && (o.fromBufferAttribute(Y, q), z[k + Q + 4] = o.x, z[k + Q + 5] = o.y, z[k + Q + 6] = o.z, z[k + Q + 7] = 0), R === !0 && (o.fromBufferAttribute(X, q), z[k + Q + 8] = o.x, z[k + Q + 9] = o.y, z[k + Q + 10] = o.z, z[k + Q + 11] = X.itemSize === 4 ? o.w : 1);
          }
        }
        v = {
          count: g,
          texture: Z,
          size: new Ie(x, y)
        }, s.set(h, v), h.addEventListener("dispose", L);
      }
      let f = 0;
      for (let b = 0; b < p.length; b++)
        f += p[b];
      const u = h.morphTargetsRelative ? 1 : 1 - f;
      d.getUniforms().setValue(i, "morphTargetBaseInfluence", u), d.getUniforms().setValue(i, "morphTargetInfluences", p), d.getUniforms().setValue(i, "morphTargetsTexture", v.texture, t), d.getUniforms().setValue(i, "morphTargetsTextureSize", v.size);
    } else {
      const m = p === void 0 ? 0 : p.length;
      let g = n[h.id];
      if (g === void 0 || g.length !== m) {
        g = [];
        for (let S = 0; S < m; S++)
          g[S] = [S, 0];
        n[h.id] = g;
      }
      for (let S = 0; S < m; S++) {
        const R = g[S];
        R[0] = S, R[1] = p[S];
      }
      g.sort(dd);
      for (let S = 0; S < 8; S++)
        S < m && g[S][1] ? (a[S][0] = g[S][0], a[S][1] = g[S][1]) : (a[S][0] = Number.MAX_SAFE_INTEGER, a[S][1] = 0);
      a.sort(hd);
      const v = h.morphAttributes.position, f = h.morphAttributes.normal;
      let u = 0;
      for (let S = 0; S < 8; S++) {
        const R = a[S], D = R[0], C = R[1];
        D !== Number.MAX_SAFE_INTEGER && C ? (v && h.getAttribute("morphTarget" + S) !== v[D] && h.setAttribute("morphTarget" + S, v[D]), f && h.getAttribute("morphNormal" + S) !== f[D] && h.setAttribute("morphNormal" + S, f[D]), r[S] = C, u += C) : (v && h.hasAttribute("morphTarget" + S) === !0 && h.deleteAttribute("morphTarget" + S), f && h.hasAttribute("morphNormal" + S) === !0 && h.deleteAttribute("morphNormal" + S), r[S] = 0);
      }
      const b = h.morphTargetsRelative ? 1 : 1 - u;
      d.getUniforms().setValue(i, "morphTargetBaseInfluence", b), d.getUniforms().setValue(i, "morphTargetInfluences", r);
    }
  }
  return {
    update: l
  };
}
function pd(i, e, t, n) {
  let r = /* @__PURE__ */ new WeakMap();
  function s(l) {
    const c = n.render.frame, h = l.geometry, d = e.get(l, h);
    if (r.get(d) !== c && (e.update(d), r.set(d, c)), l.isInstancedMesh && (l.hasEventListener("dispose", a) === !1 && l.addEventListener("dispose", a), r.get(l) !== c && (t.update(l.instanceMatrix, i.ARRAY_BUFFER), l.instanceColor !== null && t.update(l.instanceColor, i.ARRAY_BUFFER), r.set(l, c))), l.isSkinnedMesh) {
      const p = l.skeleton;
      r.get(p) !== c && (p.update(), r.set(p, c));
    }
    return d;
  }
  function o() {
    r = /* @__PURE__ */ new WeakMap();
  }
  function a(l) {
    const c = l.target;
    c.removeEventListener("dispose", a), t.remove(c.instanceMatrix), c.instanceColor !== null && t.remove(c.instanceColor);
  }
  return {
    update: s,
    dispose: o
  };
}
class Io extends bt {
  constructor(e, t, n, r, s, o, a, l, c, h) {
    if (h = h !== void 0 ? h : yn, h !== yn && h !== ti)
      throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");
    n === void 0 && h === yn && (n = sn), n === void 0 && h === ti && (n = En), super(null, r, s, o, a, l, h, n, c), this.isDepthTexture = !0, this.image = { width: e, height: t }, this.magFilter = a !== void 0 ? a : gt, this.minFilter = l !== void 0 ? l : gt, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null;
  }
  copy(e) {
    return super.copy(e), this.compareFunction = e.compareFunction, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t;
  }
}
const No = /* @__PURE__ */ new bt(), Fo = /* @__PURE__ */ new Io(1, 1);
Fo.compareFunction = xo;
const Oo = /* @__PURE__ */ new yo(), Bo = /* @__PURE__ */ new Jl(), zo = /* @__PURE__ */ new Po(), Aa = [], wa = [], Ra = new Float32Array(16), Ca = new Float32Array(9), La = new Float32Array(4);
function ri(i, e, t) {
  const n = i[0];
  if (n <= 0 || n > 0) return i;
  const r = e * t;
  let s = Aa[r];
  if (s === void 0 && (s = new Float32Array(r), Aa[r] = s), e !== 0) {
    n.toArray(s, 0);
    for (let o = 1, a = 0; o !== e; ++o)
      a += t, i[o].toArray(s, a);
  }
  return s;
}
function ot(i, e) {
  if (i.length !== e.length) return !1;
  for (let t = 0, n = i.length; t < n; t++)
    if (i[t] !== e[t]) return !1;
  return !0;
}
function lt(i, e) {
  for (let t = 0, n = e.length; t < n; t++)
    i[t] = e[t];
}
function or(i, e) {
  let t = wa[e];
  t === void 0 && (t = new Int32Array(e), wa[e] = t);
  for (let n = 0; n !== e; ++n)
    t[n] = i.allocateTextureUnit();
  return t;
}
function md(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1f(this.addr, e), t[0] = e);
}
function _d(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2f(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ot(t, e)) return;
    i.uniform2fv(this.addr, e), lt(t, e);
  }
}
function gd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3f(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else if (e.r !== void 0)
    (t[0] !== e.r || t[1] !== e.g || t[2] !== e.b) && (i.uniform3f(this.addr, e.r, e.g, e.b), t[0] = e.r, t[1] = e.g, t[2] = e.b);
  else {
    if (ot(t, e)) return;
    i.uniform3fv(this.addr, e), lt(t, e);
  }
}
function vd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4f(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ot(t, e)) return;
    i.uniform4fv(this.addr, e), lt(t, e);
  }
}
function xd(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (ot(t, e)) return;
    i.uniformMatrix2fv(this.addr, !1, e), lt(t, e);
  } else {
    if (ot(t, n)) return;
    La.set(n), i.uniformMatrix2fv(this.addr, !1, La), lt(t, n);
  }
}
function Md(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (ot(t, e)) return;
    i.uniformMatrix3fv(this.addr, !1, e), lt(t, e);
  } else {
    if (ot(t, n)) return;
    Ca.set(n), i.uniformMatrix3fv(this.addr, !1, Ca), lt(t, n);
  }
}
function Sd(i, e) {
  const t = this.cache, n = e.elements;
  if (n === void 0) {
    if (ot(t, e)) return;
    i.uniformMatrix4fv(this.addr, !1, e), lt(t, e);
  } else {
    if (ot(t, n)) return;
    Ra.set(n), i.uniformMatrix4fv(this.addr, !1, Ra), lt(t, n);
  }
}
function Ed(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1i(this.addr, e), t[0] = e);
}
function yd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2i(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ot(t, e)) return;
    i.uniform2iv(this.addr, e), lt(t, e);
  }
}
function Td(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3i(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (ot(t, e)) return;
    i.uniform3iv(this.addr, e), lt(t, e);
  }
}
function bd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4i(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ot(t, e)) return;
    i.uniform4iv(this.addr, e), lt(t, e);
  }
}
function Ad(i, e) {
  const t = this.cache;
  t[0] !== e && (i.uniform1ui(this.addr, e), t[0] = e);
}
function wd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y) && (i.uniform2ui(this.addr, e.x, e.y), t[0] = e.x, t[1] = e.y);
  else {
    if (ot(t, e)) return;
    i.uniform2uiv(this.addr, e), lt(t, e);
  }
}
function Rd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z) && (i.uniform3ui(this.addr, e.x, e.y, e.z), t[0] = e.x, t[1] = e.y, t[2] = e.z);
  else {
    if (ot(t, e)) return;
    i.uniform3uiv(this.addr, e), lt(t, e);
  }
}
function Cd(i, e) {
  const t = this.cache;
  if (e.x !== void 0)
    (t[0] !== e.x || t[1] !== e.y || t[2] !== e.z || t[3] !== e.w) && (i.uniform4ui(this.addr, e.x, e.y, e.z, e.w), t[0] = e.x, t[1] = e.y, t[2] = e.z, t[3] = e.w);
  else {
    if (ot(t, e)) return;
    i.uniform4uiv(this.addr, e), lt(t, e);
  }
}
function Ld(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r);
  const s = this.type === i.SAMPLER_2D_SHADOW ? Fo : No;
  t.setTexture2D(e || s, r);
}
function Pd(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture3D(e || Bo, r);
}
function Dd(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTextureCube(e || zo, r);
}
function Ud(i, e, t) {
  const n = this.cache, r = t.allocateTextureUnit();
  n[0] !== r && (i.uniform1i(this.addr, r), n[0] = r), t.setTexture2DArray(e || Oo, r);
}
function Id(i) {
  switch (i) {
    case 5126:
      return md;
    case 35664:
      return _d;
    case 35665:
      return gd;
    case 35666:
      return vd;
    case 35674:
      return xd;
    case 35675:
      return Md;
    case 35676:
      return Sd;
    case 5124:
    case 35670:
      return Ed;
    case 35667:
    case 35671:
      return yd;
    case 35668:
    case 35672:
      return Td;
    case 35669:
    case 35673:
      return bd;
    case 5125:
      return Ad;
    case 36294:
      return wd;
    case 36295:
      return Rd;
    case 36296:
      return Cd;
    case 35678:
    case 36198:
    case 36298:
    case 36306:
    case 35682:
      return Ld;
    case 35679:
    case 36299:
    case 36307:
      return Pd;
    case 35680:
    case 36300:
    case 36308:
    case 36293:
      return Dd;
    case 36289:
    case 36303:
    case 36311:
    case 36292:
      return Ud;
  }
}
function Nd(i, e) {
  i.uniform1fv(this.addr, e);
}
function Fd(i, e) {
  const t = ri(e, this.size, 2);
  i.uniform2fv(this.addr, t);
}
function Od(i, e) {
  const t = ri(e, this.size, 3);
  i.uniform3fv(this.addr, t);
}
function Bd(i, e) {
  const t = ri(e, this.size, 4);
  i.uniform4fv(this.addr, t);
}
function zd(i, e) {
  const t = ri(e, this.size, 4);
  i.uniformMatrix2fv(this.addr, !1, t);
}
function Gd(i, e) {
  const t = ri(e, this.size, 9);
  i.uniformMatrix3fv(this.addr, !1, t);
}
function Hd(i, e) {
  const t = ri(e, this.size, 16);
  i.uniformMatrix4fv(this.addr, !1, t);
}
function Vd(i, e) {
  i.uniform1iv(this.addr, e);
}
function kd(i, e) {
  i.uniform2iv(this.addr, e);
}
function Wd(i, e) {
  i.uniform3iv(this.addr, e);
}
function Xd(i, e) {
  i.uniform4iv(this.addr, e);
}
function qd(i, e) {
  i.uniform1uiv(this.addr, e);
}
function Yd(i, e) {
  i.uniform2uiv(this.addr, e);
}
function jd(i, e) {
  i.uniform3uiv(this.addr, e);
}
function Kd(i, e) {
  i.uniform4uiv(this.addr, e);
}
function Zd(i, e, t) {
  const n = this.cache, r = e.length, s = or(t, r);
  ot(n, s) || (i.uniform1iv(this.addr, s), lt(n, s));
  for (let o = 0; o !== r; ++o)
    t.setTexture2D(e[o] || No, s[o]);
}
function $d(i, e, t) {
  const n = this.cache, r = e.length, s = or(t, r);
  ot(n, s) || (i.uniform1iv(this.addr, s), lt(n, s));
  for (let o = 0; o !== r; ++o)
    t.setTexture3D(e[o] || Bo, s[o]);
}
function Jd(i, e, t) {
  const n = this.cache, r = e.length, s = or(t, r);
  ot(n, s) || (i.uniform1iv(this.addr, s), lt(n, s));
  for (let o = 0; o !== r; ++o)
    t.setTextureCube(e[o] || zo, s[o]);
}
function Qd(i, e, t) {
  const n = this.cache, r = e.length, s = or(t, r);
  ot(n, s) || (i.uniform1iv(this.addr, s), lt(n, s));
  for (let o = 0; o !== r; ++o)
    t.setTexture2DArray(e[o] || Oo, s[o]);
}
function ef(i) {
  switch (i) {
    case 5126:
      return Nd;
    case 35664:
      return Fd;
    case 35665:
      return Od;
    case 35666:
      return Bd;
    case 35674:
      return zd;
    case 35675:
      return Gd;
    case 35676:
      return Hd;
    case 5124:
    case 35670:
      return Vd;
    case 35667:
    case 35671:
      return kd;
    case 35668:
    case 35672:
      return Wd;
    case 35669:
    case 35673:
      return Xd;
    case 5125:
      return qd;
    case 36294:
      return Yd;
    case 36295:
      return jd;
    case 36296:
      return Kd;
    case 35678:
    case 36198:
    case 36298:
    case 36306:
    case 35682:
      return Zd;
    case 35679:
    case 36299:
    case 36307:
      return $d;
    case 35680:
    case 36300:
    case 36308:
    case 36293:
      return Jd;
    case 36289:
    case 36303:
    case 36311:
    case 36292:
      return Qd;
  }
}
class tf {
  constructor(e, t, n) {
    this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = Id(t.type);
  }
}
class nf {
  constructor(e, t, n) {
    this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = ef(t.type);
  }
}
class rf {
  constructor(e) {
    this.id = e, this.seq = [], this.map = {};
  }
  setValue(e, t, n) {
    const r = this.seq;
    for (let s = 0, o = r.length; s !== o; ++s) {
      const a = r[s];
      a.setValue(e, t[a.id], n);
    }
  }
}
const Vr = /(\w+)(\])?(\[|\.)?/g;
function Pa(i, e) {
  i.seq.push(e), i.map[e.id] = e;
}
function sf(i, e, t) {
  const n = i.name, r = n.length;
  for (Vr.lastIndex = 0; ; ) {
    const s = Vr.exec(n), o = Vr.lastIndex;
    let a = s[1];
    const l = s[2] === "]", c = s[3];
    if (l && (a = a | 0), c === void 0 || c === "[" && o + 2 === r) {
      Pa(t, c === void 0 ? new tf(a, i, e) : new nf(a, i, e));
      break;
    } else {
      let d = t.map[a];
      d === void 0 && (d = new rf(a), Pa(t, d)), t = d;
    }
  }
}
class Zi {
  constructor(e, t) {
    this.seq = [], this.map = {};
    const n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS);
    for (let r = 0; r < n; ++r) {
      const s = e.getActiveUniform(t, r), o = e.getUniformLocation(t, s.name);
      sf(s, o, this);
    }
  }
  setValue(e, t, n, r) {
    const s = this.map[t];
    s !== void 0 && s.setValue(e, n, r);
  }
  setOptional(e, t, n) {
    const r = t[n];
    r !== void 0 && this.setValue(e, n, r);
  }
  static upload(e, t, n, r) {
    for (let s = 0, o = t.length; s !== o; ++s) {
      const a = t[s], l = n[a.id];
      l.needsUpdate !== !1 && a.setValue(e, l.value, r);
    }
  }
  static seqWithValue(e, t) {
    const n = [];
    for (let r = 0, s = e.length; r !== s; ++r) {
      const o = e[r];
      o.id in t && n.push(o);
    }
    return n;
  }
}
function Da(i, e, t) {
  const n = i.createShader(e);
  return i.shaderSource(n, t), i.compileShader(n), n;
}
const af = 37297;
let of = 0;
function lf(i, e) {
  const t = i.split(`
`), n = [], r = Math.max(e - 6, 0), s = Math.min(e + 6, t.length);
  for (let o = r; o < s; o++) {
    const a = o + 1;
    n.push(`${a === e ? ">" : " "} ${a}: ${t[o]}`);
  }
  return n.join(`
`);
}
function cf(i) {
  const e = Ke.getPrimaries(Ke.workingColorSpace), t = Ke.getPrimaries(i);
  let n;
  switch (e === t ? n = "" : e === er && t === Qi ? n = "LinearDisplayP3ToLinearSRGB" : e === Qi && t === er && (n = "LinearSRGBToLinearDisplayP3"), i) {
    case $t:
    case sr:
      return [n, "LinearTransferOETF"];
    case ht:
    case os:
      return [n, "sRGBTransferOETF"];
    default:
      return console.warn("THREE.WebGLProgram: Unsupported color space:", i), [n, "LinearTransferOETF"];
  }
}
function Ua(i, e, t) {
  const n = i.getShaderParameter(e, i.COMPILE_STATUS), r = i.getShaderInfoLog(e).trim();
  if (n && r === "") return "";
  const s = /ERROR: 0:(\d+)/.exec(r);
  if (s) {
    const o = parseInt(s[1]);
    return t.toUpperCase() + `

` + r + `

` + lf(i.getShaderSource(e), o);
  } else
    return r;
}
function uf(i, e) {
  const t = cf(e);
  return `vec4 ${i}( vec4 value ) { return ${t[0]}( ${t[1]}( value ) ); }`;
}
function hf(i, e) {
  let t;
  switch (e) {
    case Ml:
      t = "Linear";
      break;
    case Sl:
      t = "Reinhard";
      break;
    case El:
      t = "OptimizedCineon";
      break;
    case yl:
      t = "ACESFilmic";
      break;
    case bl:
      t = "AgX";
      break;
    case Tl:
      t = "Custom";
      break;
    default:
      console.warn("THREE.WebGLProgram: Unsupported toneMapping:", e), t = "Linear";
  }
  return "vec3 " + i + "( vec3 color ) { return " + t + "ToneMapping( color ); }";
}
function df(i) {
  return [
    i.extensionDerivatives || i.envMapCubeUVHeight || i.bumpMap || i.normalMapTangentSpace || i.clearcoatNormalMap || i.flatShading || i.shaderID === "physical" ? "#extension GL_OES_standard_derivatives : enable" : "",
    (i.extensionFragDepth || i.logarithmicDepthBuffer) && i.rendererExtensionFragDepth ? "#extension GL_EXT_frag_depth : enable" : "",
    i.extensionDrawBuffers && i.rendererExtensionDrawBuffers ? "#extension GL_EXT_draw_buffers : require" : "",
    (i.extensionShaderTextureLOD || i.envMap || i.transmission) && i.rendererExtensionShaderTextureLod ? "#extension GL_EXT_shader_texture_lod : enable" : ""
  ].filter(Zn).join(`
`);
}
function ff(i) {
  return [
    i.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : ""
  ].filter(Zn).join(`
`);
}
function pf(i) {
  const e = [];
  for (const t in i) {
    const n = i[t];
    n !== !1 && e.push("#define " + t + " " + n);
  }
  return e.join(`
`);
}
function mf(i, e) {
  const t = {}, n = i.getProgramParameter(e, i.ACTIVE_ATTRIBUTES);
  for (let r = 0; r < n; r++) {
    const s = i.getActiveAttrib(e, r), o = s.name;
    let a = 1;
    s.type === i.FLOAT_MAT2 && (a = 2), s.type === i.FLOAT_MAT3 && (a = 3), s.type === i.FLOAT_MAT4 && (a = 4), t[o] = {
      type: s.type,
      location: i.getAttribLocation(e, o),
      locationSize: a
    };
  }
  return t;
}
function Zn(i) {
  return i !== "";
}
function Ia(i, e) {
  const t = e.numSpotLightShadows + e.numSpotLightMaps - e.numSpotLightShadowsWithMaps;
  return i.replace(/NUM_DIR_LIGHTS/g, e.numDirLights).replace(/NUM_SPOT_LIGHTS/g, e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, t).replace(/NUM_RECT_AREA_LIGHTS/g, e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, e.numPointLights).replace(/NUM_HEMI_LIGHTS/g, e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, e.numPointLightShadows);
}
function Na(i, e) {
  return i.replace(/NUM_CLIPPING_PLANES/g, e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, e.numClippingPlanes - e.numClipIntersection);
}
const _f = /^[ \t]*#include +<([\w\d./]+)>/gm;
function rs(i) {
  return i.replace(_f, vf);
}
const gf = /* @__PURE__ */ new Map([
  ["encodings_fragment", "colorspace_fragment"],
  // @deprecated, r154
  ["encodings_pars_fragment", "colorspace_pars_fragment"],
  // @deprecated, r154
  ["output_fragment", "opaque_fragment"]
  // @deprecated, r154
]);
function vf(i, e) {
  let t = Be[e];
  if (t === void 0) {
    const n = gf.get(e);
    if (n !== void 0)
      t = Be[n], console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.', e, n);
    else
      throw new Error("Can not resolve #include <" + e + ">");
  }
  return rs(t);
}
const xf = /#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 Fa(i) {
  return i.replace(xf, Mf);
}
function Mf(i, e, t, n) {
  let r = "";
  for (let s = parseInt(e); s < parseInt(t); s++)
    r += n.replace(/\[\s*i\s*\]/g, "[ " + s + " ]").replace(/UNROLLED_LOOP_INDEX/g, s);
  return r;
}
function Oa(i) {
  let e = "precision " + i.precision + ` float;
precision ` + i.precision + " int;";
  return i.precision === "highp" ? e += `
#define HIGH_PRECISION` : i.precision === "mediump" ? e += `
#define MEDIUM_PRECISION` : i.precision === "lowp" && (e += `
#define LOW_PRECISION`), e;
}
function Sf(i) {
  let e = "SHADOWMAP_TYPE_BASIC";
  return i.shadowMapType === so ? e = "SHADOWMAP_TYPE_PCF" : i.shadowMapType === ao ? e = "SHADOWMAP_TYPE_PCF_SOFT" : i.shadowMapType === jt && (e = "SHADOWMAP_TYPE_VSM"), e;
}
function Ef(i) {
  let e = "ENVMAP_TYPE_CUBE";
  if (i.envMap)
    switch (i.envMapMode) {
      case Qn:
      case ei:
        e = "ENVMAP_TYPE_CUBE";
        break;
      case rr:
        e = "ENVMAP_TYPE_CUBE_UV";
        break;
    }
  return e;
}
function yf(i) {
  let e = "ENVMAP_MODE_REFLECTION";
  if (i.envMap)
    switch (i.envMapMode) {
      case ei:
        e = "ENVMAP_MODE_REFRACTION";
        break;
    }
  return e;
}
function Tf(i) {
  let e = "ENVMAP_BLENDING_NONE";
  if (i.envMap)
    switch (i.combine) {
      case oo:
        e = "ENVMAP_BLENDING_MULTIPLY";
        break;
      case vl:
        e = "ENVMAP_BLENDING_MIX";
        break;
      case xl:
        e = "ENVMAP_BLENDING_ADD";
        break;
    }
  return e;
}
function bf(i) {
  const e = i.envMapCubeUVHeight;
  if (e === null) return null;
  const t = Math.log2(e) - 2, n = 1 / e;
  return { texelWidth: 1 / (3 * Math.max(Math.pow(2, t), 7 * 16)), texelHeight: n, maxMip: t };
}
function Af(i, e, t, n) {
  const r = i.getContext(), s = t.defines;
  let o = t.vertexShader, a = t.fragmentShader;
  const l = Sf(t), c = Ef(t), h = yf(t), d = Tf(t), p = bf(t), m = t.isWebGL2 ? "" : df(t), g = ff(t), v = pf(s), f = r.createProgram();
  let u, b, S = t.glslVersion ? "#version " + t.glslVersion + `
` : "";
  t.isRawShaderMaterial ? (u = [
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v
  ].filter(Zn).join(`
`), u.length > 0 && (u += `
`), b = [
    m,
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v
  ].filter(Zn).join(`
`), b.length > 0 && (b += `
`)) : (u = [
    Oa(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v,
    t.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "",
    t.batching ? "#define USE_BATCHING" : "",
    t.instancing ? "#define USE_INSTANCING" : "",
    t.instancingColor ? "#define USE_INSTANCING_COLOR" : "",
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.map ? "#define USE_MAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + h : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.displacementMap ? "#define USE_DISPLACEMENTMAP" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    //
    t.mapUv ? "#define MAP_UV " + t.mapUv : "",
    t.alphaMapUv ? "#define ALPHAMAP_UV " + t.alphaMapUv : "",
    t.lightMapUv ? "#define LIGHTMAP_UV " + t.lightMapUv : "",
    t.aoMapUv ? "#define AOMAP_UV " + t.aoMapUv : "",
    t.emissiveMapUv ? "#define EMISSIVEMAP_UV " + t.emissiveMapUv : "",
    t.bumpMapUv ? "#define BUMPMAP_UV " + t.bumpMapUv : "",
    t.normalMapUv ? "#define NORMALMAP_UV " + t.normalMapUv : "",
    t.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + t.displacementMapUv : "",
    t.metalnessMapUv ? "#define METALNESSMAP_UV " + t.metalnessMapUv : "",
    t.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + t.roughnessMapUv : "",
    t.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + t.anisotropyMapUv : "",
    t.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + t.clearcoatMapUv : "",
    t.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + t.clearcoatNormalMapUv : "",
    t.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + t.clearcoatRoughnessMapUv : "",
    t.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + t.iridescenceMapUv : "",
    t.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + t.iridescenceThicknessMapUv : "",
    t.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + t.sheenColorMapUv : "",
    t.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + t.sheenRoughnessMapUv : "",
    t.specularMapUv ? "#define SPECULARMAP_UV " + t.specularMapUv : "",
    t.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + t.specularColorMapUv : "",
    t.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + t.specularIntensityMapUv : "",
    t.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + t.transmissionMapUv : "",
    t.thicknessMapUv ? "#define THICKNESSMAP_UV " + t.thicknessMapUv : "",
    //
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.skinning ? "#define USE_SKINNING" : "",
    t.morphTargets ? "#define USE_MORPHTARGETS" : "",
    t.morphNormals && t.flatShading === !1 ? "#define USE_MORPHNORMALS" : "",
    t.morphColors && t.isWebGL2 ? "#define USE_MORPHCOLORS" : "",
    t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE" : "",
    t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + t.morphTextureStride : "",
    t.morphTargetsCount > 0 && t.isWebGL2 ? "#define MORPHTARGETS_COUNT " + t.morphTargetsCount : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + l : "",
    t.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.useLegacyLights ? "#define LEGACY_LIGHTS" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
    "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",
    "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",
    "#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )",
    "	attribute vec3 morphTarget0;",
    "	attribute vec3 morphTarget1;",
    "	attribute vec3 morphTarget2;",
    "	attribute vec3 morphTarget3;",
    "	#ifdef USE_MORPHNORMALS",
    "		attribute vec3 morphNormal0;",
    "		attribute vec3 morphNormal1;",
    "		attribute vec3 morphNormal2;",
    "		attribute vec3 morphNormal3;",
    "	#else",
    "		attribute vec3 morphTarget4;",
    "		attribute vec3 morphTarget5;",
    "		attribute vec3 morphTarget6;",
    "		attribute vec3 morphTarget7;",
    "	#endif",
    "#endif",
    "#ifdef USE_SKINNING",
    "	attribute vec4 skinIndex;",
    "	attribute vec4 skinWeight;",
    "#endif",
    `
`
  ].filter(Zn).join(`
`), b = [
    m,
    Oa(t),
    "#define SHADER_TYPE " + t.shaderType,
    "#define SHADER_NAME " + t.shaderName,
    v,
    t.useFog && t.fog ? "#define USE_FOG" : "",
    t.useFog && t.fogExp2 ? "#define FOG_EXP2" : "",
    t.map ? "#define USE_MAP" : "",
    t.matcap ? "#define USE_MATCAP" : "",
    t.envMap ? "#define USE_ENVMAP" : "",
    t.envMap ? "#define " + c : "",
    t.envMap ? "#define " + h : "",
    t.envMap ? "#define " + d : "",
    p ? "#define CUBEUV_TEXEL_WIDTH " + p.texelWidth : "",
    p ? "#define CUBEUV_TEXEL_HEIGHT " + p.texelHeight : "",
    p ? "#define CUBEUV_MAX_MIP " + p.maxMip + ".0" : "",
    t.lightMap ? "#define USE_LIGHTMAP" : "",
    t.aoMap ? "#define USE_AOMAP" : "",
    t.bumpMap ? "#define USE_BUMPMAP" : "",
    t.normalMap ? "#define USE_NORMALMAP" : "",
    t.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "",
    t.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "",
    t.emissiveMap ? "#define USE_EMISSIVEMAP" : "",
    t.anisotropy ? "#define USE_ANISOTROPY" : "",
    t.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "",
    t.clearcoat ? "#define USE_CLEARCOAT" : "",
    t.clearcoatMap ? "#define USE_CLEARCOATMAP" : "",
    t.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "",
    t.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "",
    t.iridescence ? "#define USE_IRIDESCENCE" : "",
    t.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "",
    t.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "",
    t.specularMap ? "#define USE_SPECULARMAP" : "",
    t.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "",
    t.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "",
    t.roughnessMap ? "#define USE_ROUGHNESSMAP" : "",
    t.metalnessMap ? "#define USE_METALNESSMAP" : "",
    t.alphaMap ? "#define USE_ALPHAMAP" : "",
    t.alphaTest ? "#define USE_ALPHATEST" : "",
    t.alphaHash ? "#define USE_ALPHAHASH" : "",
    t.sheen ? "#define USE_SHEEN" : "",
    t.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "",
    t.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "",
    t.transmission ? "#define USE_TRANSMISSION" : "",
    t.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "",
    t.thicknessMap ? "#define USE_THICKNESSMAP" : "",
    t.vertexTangents && t.flatShading === !1 ? "#define USE_TANGENT" : "",
    t.vertexColors || t.instancingColor ? "#define USE_COLOR" : "",
    t.vertexAlphas ? "#define USE_COLOR_ALPHA" : "",
    t.vertexUv1s ? "#define USE_UV1" : "",
    t.vertexUv2s ? "#define USE_UV2" : "",
    t.vertexUv3s ? "#define USE_UV3" : "",
    t.pointsUvs ? "#define USE_POINTS_UV" : "",
    t.gradientMap ? "#define USE_GRADIENTMAP" : "",
    t.flatShading ? "#define FLAT_SHADED" : "",
    t.doubleSided ? "#define DOUBLE_SIDED" : "",
    t.flipSided ? "#define FLIP_SIDED" : "",
    t.shadowMapEnabled ? "#define USE_SHADOWMAP" : "",
    t.shadowMapEnabled ? "#define " + l : "",
    t.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "",
    t.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "",
    t.useLegacyLights ? "#define LEGACY_LIGHTS" : "",
    t.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "",
    t.logarithmicDepthBuffer ? "#define USE_LOGDEPTHBUF" : "",
    t.logarithmicDepthBuffer && t.rendererExtensionFragDepth ? "#define USE_LOGDEPTHBUF_EXT" : "",
    "uniform mat4 viewMatrix;",
    "uniform vec3 cameraPosition;",
    "uniform bool isOrthographic;",
    t.toneMapping !== ln ? "#define TONE_MAPPING" : "",
    t.toneMapping !== ln ? Be.tonemapping_pars_fragment : "",
    // this code is required here because it is used by the toneMapping() function defined below
    t.toneMapping !== ln ? hf("toneMapping", t.toneMapping) : "",
    t.dithering ? "#define DITHERING" : "",
    t.opaque ? "#define OPAQUE" : "",
    Be.colorspace_pars_fragment,
    // this code is required here because it is used by the various encoding/decoding function defined below
    uf("linearToOutputTexel", t.outputColorSpace),
    t.useDepthPacking ? "#define DEPTH_PACKING " + t.depthPacking : "",
    `
`
  ].filter(Zn).join(`
`)), o = rs(o), o = Ia(o, t), o = Na(o, t), a = rs(a), a = Ia(a, t), a = Na(a, t), o = Fa(o), a = Fa(a), t.isWebGL2 && t.isRawShaderMaterial !== !0 && (S = `#version 300 es
`, u = [
    g,
    "precision mediump sampler2DArray;",
    "#define attribute in",
    "#define varying out",
    "#define texture2D texture"
  ].join(`
`) + `
` + u, b = [
    "precision mediump sampler2DArray;",
    "#define varying in",
    t.glslVersion === ta ? "" : "layout(location = 0) out highp vec4 pc_fragColor;",
    t.glslVersion === ta ? "" : "#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(`
`) + `
` + b);
  const R = S + u + o, D = S + b + a, C = Da(r, r.VERTEX_SHADER, R), A = Da(r, r.FRAGMENT_SHADER, D);
  r.attachShader(f, C), r.attachShader(f, A), t.index0AttributeName !== void 0 ? r.bindAttribLocation(f, 0, t.index0AttributeName) : t.morphTargets === !0 && r.bindAttribLocation(f, 0, "position"), r.linkProgram(f);
  function W(Z) {
    if (i.debug.checkShaderErrors) {
      const re = r.getProgramInfoLog(f).trim(), L = r.getShaderInfoLog(C).trim(), F = r.getShaderInfoLog(A).trim();
      let V = !0, Y = !0;
      if (r.getProgramParameter(f, r.LINK_STATUS) === !1)
        if (V = !1, typeof i.debug.onShaderError == "function")
          i.debug.onShaderError(r, f, C, A);
        else {
          const X = Ua(r, C, "vertex"), k = Ua(r, A, "fragment");
          console.error(
            "THREE.WebGLProgram: Shader Error " + r.getError() + " - VALIDATE_STATUS " + r.getProgramParameter(f, r.VALIDATE_STATUS) + `

Program Info Log: ` + re + `
` + X + `
` + k
          );
        }
      else re !== "" ? console.warn("THREE.WebGLProgram: Program Info Log:", re) : (L === "" || F === "") && (Y = !1);
      Y && (Z.diagnostics = {
        runnable: V,
        programLog: re,
        vertexShader: {
          log: L,
          prefix: u
        },
        fragmentShader: {
          log: F,
          prefix: b
        }
      });
    }
    r.deleteShader(C), r.deleteShader(A), x = new Zi(r, f), y = mf(r, f);
  }
  let x;
  this.getUniforms = function() {
    return x === void 0 && W(this), x;
  };
  let y;
  this.getAttributes = function() {
    return y === void 0 && W(this), y;
  };
  let z = t.rendererExtensionParallelShaderCompile === !1;
  return this.isReady = function() {
    return z === !1 && (z = r.getProgramParameter(f, af)), z;
  }, this.destroy = function() {
    n.releaseStatesOfProgram(this), r.deleteProgram(f), this.program = void 0;
  }, this.type = t.shaderType, this.name = t.shaderName, this.id = of++, this.cacheKey = e, this.usedTimes = 1, this.program = f, this.vertexShader = C, this.fragmentShader = A, this;
}
let wf = 0;
class Rf {
  constructor() {
    this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map();
  }
  update(e) {
    const t = e.vertexShader, n = e.fragmentShader, r = this._getShaderStage(t), s = this._getShaderStage(n), o = this._getShaderCacheForMaterial(e);
    return o.has(r) === !1 && (o.add(r), r.usedTimes++), o.has(s) === !1 && (o.add(s), s.usedTimes++), this;
  }
  remove(e) {
    const t = this.materialCache.get(e);
    for (const n of t)
      n.usedTimes--, n.usedTimes === 0 && this.shaderCache.delete(n.code);
    return this.materialCache.delete(e), this;
  }
  getVertexShaderID(e) {
    return this._getShaderStage(e.vertexShader).id;
  }
  getFragmentShaderID(e) {
    return this._getShaderStage(e.fragmentShader).id;
  }
  dispose() {
    this.shaderCache.clear(), this.materialCache.clear();
  }
  _getShaderCacheForMaterial(e) {
    const t = this.materialCache;
    let n = t.get(e);
    return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n;
  }
  _getShaderStage(e) {
    const t = this.shaderCache;
    let n = t.get(e);
    return n === void 0 && (n = new Cf(e), t.set(e, n)), n;
  }
}
class Cf {
  constructor(e) {
    this.id = wf++, this.code = e, this.usedTimes = 0;
  }
}
function Lf(i, e, t, n, r, s, o) {
  const a = new bo(), l = new Rf(), c = [], h = r.isWebGL2, d = r.logarithmicDepthBuffer, p = r.vertexTextures;
  let m = r.precision;
  const g = {
    MeshDepthMaterial: "depth",
    MeshDistanceMaterial: "distanceRGBA",
    MeshNormalMaterial: "normal",
    MeshBasicMaterial: "basic",
    MeshLambertMaterial: "lambert",
    MeshPhongMaterial: "phong",
    MeshToonMaterial: "toon",
    MeshStandardMaterial: "physical",
    MeshPhysicalMaterial: "physical",
    MeshMatcapMaterial: "matcap",
    LineBasicMaterial: "basic",
    LineDashedMaterial: "dashed",
    PointsMaterial: "points",
    ShadowMaterial: "shadow",
    SpriteMaterial: "sprite"
  };
  function v(x) {
    return x === 0 ? "uv" : `uv${x}`;
  }
  function f(x, y, z, Z, re) {
    const L = Z.fog, F = re.geometry, V = x.isMeshStandardMaterial ? Z.environment : null, Y = (x.isMeshStandardMaterial ? t : e).get(x.envMap || V), X = Y && Y.mapping === rr ? Y.image.height : null, k = g[x.type];
    x.precision !== null && (m = r.getMaxPrecision(x.precision), m !== x.precision && console.warn("THREE.WebGLProgram.getParameters:", x.precision, "not supported, using", m, "instead."));
    const q = F.morphAttributes.position || F.morphAttributes.normal || F.morphAttributes.color, Q = q !== void 0 ? q.length : 0;
    let ce = 0;
    F.morphAttributes.position !== void 0 && (ce = 1), F.morphAttributes.normal !== void 0 && (ce = 2), F.morphAttributes.color !== void 0 && (ce = 3);
    let H, j, oe, ve;
    if (k) {
      const nt = Gt[k];
      H = nt.vertexShader, j = nt.fragmentShader;
    } else
      H = x.vertexShader, j = x.fragmentShader, l.update(x), oe = l.getVertexShaderID(x), ve = l.getFragmentShaderID(x);
    const _e = i.getRenderTarget(), we = re.isInstancedMesh === !0, Ae = re.isBatchedMesh === !0, ge = !!x.map, Pe = !!x.matcap, N = !!Y, rt = !!x.aoMap, Me = !!x.lightMap, Re = !!x.bumpMap, pe = !!x.normalMap, je = !!x.displacementMap, be = !!x.emissiveMap, M = !!x.metalnessMap, _ = !!x.roughnessMap, I = x.anisotropy > 0, $ = x.clearcoat > 0, K = x.iridescence > 0, J = x.sheen > 0, me = x.transmission > 0, ae = I && !!x.anisotropyMap, he = $ && !!x.clearcoatMap, ye = $ && !!x.clearcoatNormalMap, Fe = $ && !!x.clearcoatRoughnessMap, ee = K && !!x.iridescenceMap, Ye = K && !!x.iridescenceThicknessMap, ze = J && !!x.sheenColorMap, De = J && !!x.sheenRoughnessMap, Ee = !!x.specularMap, ue = !!x.specularColorMap, T = !!x.specularIntensityMap, ne = me && !!x.transmissionMap, xe = me && !!x.thicknessMap, fe = !!x.gradientMap, te = !!x.alphaMap, w = x.alphaTest > 0, ie = !!x.alphaHash, le = !!x.extensions, Ce = !!F.attributes.uv1, Te = !!F.attributes.uv2, ke = !!F.attributes.uv3;
    let We = ln;
    return x.toneMapped && (_e === null || _e.isXRRenderTarget === !0) && (We = i.toneMapping), {
      isWebGL2: h,
      shaderID: k,
      shaderType: x.type,
      shaderName: x.name,
      vertexShader: H,
      fragmentShader: j,
      defines: x.defines,
      customVertexShaderID: oe,
      customFragmentShaderID: ve,
      isRawShaderMaterial: x.isRawShaderMaterial === !0,
      glslVersion: x.glslVersion,
      precision: m,
      batching: Ae,
      instancing: we,
      instancingColor: we && re.instanceColor !== null,
      supportsVertexTextures: p,
      outputColorSpace: _e === null ? i.outputColorSpace : _e.isXRRenderTarget === !0 ? _e.texture.colorSpace : $t,
      map: ge,
      matcap: Pe,
      envMap: N,
      envMapMode: N && Y.mapping,
      envMapCubeUVHeight: X,
      aoMap: rt,
      lightMap: Me,
      bumpMap: Re,
      normalMap: pe,
      displacementMap: p && je,
      emissiveMap: be,
      normalMapObjectSpace: pe && x.normalMapType === Ol,
      normalMapTangentSpace: pe && x.normalMapType === vo,
      metalnessMap: M,
      roughnessMap: _,
      anisotropy: I,
      anisotropyMap: ae,
      clearcoat: $,
      clearcoatMap: he,
      clearcoatNormalMap: ye,
      clearcoatRoughnessMap: Fe,
      iridescence: K,
      iridescenceMap: ee,
      iridescenceThicknessMap: Ye,
      sheen: J,
      sheenColorMap: ze,
      sheenRoughnessMap: De,
      specularMap: Ee,
      specularColorMap: ue,
      specularIntensityMap: T,
      transmission: me,
      transmissionMap: ne,
      thicknessMap: xe,
      gradientMap: fe,
      opaque: x.transparent === !1 && x.blending === $n,
      alphaMap: te,
      alphaTest: w,
      alphaHash: ie,
      combine: x.combine,
      //
      mapUv: ge && v(x.map.channel),
      aoMapUv: rt && v(x.aoMap.channel),
      lightMapUv: Me && v(x.lightMap.channel),
      bumpMapUv: Re && v(x.bumpMap.channel),
      normalMapUv: pe && v(x.normalMap.channel),
      displacementMapUv: je && v(x.displacementMap.channel),
      emissiveMapUv: be && v(x.emissiveMap.channel),
      metalnessMapUv: M && v(x.metalnessMap.channel),
      roughnessMapUv: _ && v(x.roughnessMap.channel),
      anisotropyMapUv: ae && v(x.anisotropyMap.channel),
      clearcoatMapUv: he && v(x.clearcoatMap.channel),
      clearcoatNormalMapUv: ye && v(x.clearcoatNormalMap.channel),
      clearcoatRoughnessMapUv: Fe && v(x.clearcoatRoughnessMap.channel),
      iridescenceMapUv: ee && v(x.iridescenceMap.channel),
      iridescenceThicknessMapUv: Ye && v(x.iridescenceThicknessMap.channel),
      sheenColorMapUv: ze && v(x.sheenColorMap.channel),
      sheenRoughnessMapUv: De && v(x.sheenRoughnessMap.channel),
      specularMapUv: Ee && v(x.specularMap.channel),
      specularColorMapUv: ue && v(x.specularColorMap.channel),
      specularIntensityMapUv: T && v(x.specularIntensityMap.channel),
      transmissionMapUv: ne && v(x.transmissionMap.channel),
      thicknessMapUv: xe && v(x.thicknessMap.channel),
      alphaMapUv: te && v(x.alphaMap.channel),
      //
      vertexTangents: !!F.attributes.tangent && (pe || I),
      vertexColors: x.vertexColors,
      vertexAlphas: x.vertexColors === !0 && !!F.attributes.color && F.attributes.color.itemSize === 4,
      vertexUv1s: Ce,
      vertexUv2s: Te,
      vertexUv3s: ke,
      pointsUvs: re.isPoints === !0 && !!F.attributes.uv && (ge || te),
      fog: !!L,
      useFog: x.fog === !0,
      fogExp2: L && L.isFogExp2,
      flatShading: x.flatShading === !0,
      sizeAttenuation: x.sizeAttenuation === !0,
      logarithmicDepthBuffer: d,
      skinning: re.isSkinnedMesh === !0,
      morphTargets: F.morphAttributes.position !== void 0,
      morphNormals: F.morphAttributes.normal !== void 0,
      morphColors: F.morphAttributes.color !== void 0,
      morphTargetsCount: Q,
      morphTextureStride: ce,
      numDirLights: y.directional.length,
      numPointLights: y.point.length,
      numSpotLights: y.spot.length,
      numSpotLightMaps: y.spotLightMap.length,
      numRectAreaLights: y.rectArea.length,
      numHemiLights: y.hemi.length,
      numDirLightShadows: y.directionalShadowMap.length,
      numPointLightShadows: y.pointShadowMap.length,
      numSpotLightShadows: y.spotShadowMap.length,
      numSpotLightShadowsWithMaps: y.numSpotLightShadowsWithMaps,
      numLightProbes: y.numLightProbes,
      numClippingPlanes: o.numPlanes,
      numClipIntersection: o.numIntersection,
      dithering: x.dithering,
      shadowMapEnabled: i.shadowMap.enabled && z.length > 0,
      shadowMapType: i.shadowMap.type,
      toneMapping: We,
      useLegacyLights: i._useLegacyLights,
      decodeVideoTexture: ge && x.map.isVideoTexture === !0 && Ke.getTransfer(x.map.colorSpace) === Ze,
      premultipliedAlpha: x.premultipliedAlpha,
      doubleSided: x.side === Kt,
      flipSided: x.side === Mt,
      useDepthPacking: x.depthPacking >= 0,
      depthPacking: x.depthPacking || 0,
      index0AttributeName: x.index0AttributeName,
      extensionDerivatives: le && x.extensions.derivatives === !0,
      extensionFragDepth: le && x.extensions.fragDepth === !0,
      extensionDrawBuffers: le && x.extensions.drawBuffers === !0,
      extensionShaderTextureLOD: le && x.extensions.shaderTextureLOD === !0,
      extensionClipCullDistance: le && x.extensions.clipCullDistance && n.has("WEBGL_clip_cull_distance"),
      rendererExtensionFragDepth: h || n.has("EXT_frag_depth"),
      rendererExtensionDrawBuffers: h || n.has("WEBGL_draw_buffers"),
      rendererExtensionShaderTextureLod: h || n.has("EXT_shader_texture_lod"),
      rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"),
      customProgramCacheKey: x.customProgramCacheKey()
    };
  }
  function u(x) {
    const y = [];
    if (x.shaderID ? y.push(x.shaderID) : (y.push(x.customVertexShaderID), y.push(x.customFragmentShaderID)), x.defines !== void 0)
      for (const z in x.defines)
        y.push(z), y.push(x.defines[z]);
    return x.isRawShaderMaterial === !1 && (b(y, x), S(y, x), y.push(i.outputColorSpace)), y.push(x.customProgramCacheKey), y.join();
  }
  function b(x, y) {
    x.push(y.precision), x.push(y.outputColorSpace), x.push(y.envMapMode), x.push(y.envMapCubeUVHeight), x.push(y.mapUv), x.push(y.alphaMapUv), x.push(y.lightMapUv), x.push(y.aoMapUv), x.push(y.bumpMapUv), x.push(y.normalMapUv), x.push(y.displacementMapUv), x.push(y.emissiveMapUv), x.push(y.metalnessMapUv), x.push(y.roughnessMapUv), x.push(y.anisotropyMapUv), x.push(y.clearcoatMapUv), x.push(y.clearcoatNormalMapUv), x.push(y.clearcoatRoughnessMapUv), x.push(y.iridescenceMapUv), x.push(y.iridescenceThicknessMapUv), x.push(y.sheenColorMapUv), x.push(y.sheenRoughnessMapUv), x.push(y.specularMapUv), x.push(y.specularColorMapUv), x.push(y.specularIntensityMapUv), x.push(y.transmissionMapUv), x.push(y.thicknessMapUv), x.push(y.combine), x.push(y.fogExp2), x.push(y.sizeAttenuation), x.push(y.morphTargetsCount), x.push(y.morphAttributeCount), x.push(y.numDirLights), x.push(y.numPointLights), x.push(y.numSpotLights), x.push(y.numSpotLightMaps), x.push(y.numHemiLights), x.push(y.numRectAreaLights), x.push(y.numDirLightShadows), x.push(y.numPointLightShadows), x.push(y.numSpotLightShadows), x.push(y.numSpotLightShadowsWithMaps), x.push(y.numLightProbes), x.push(y.shadowMapType), x.push(y.toneMapping), x.push(y.numClippingPlanes), x.push(y.numClipIntersection), x.push(y.depthPacking);
  }
  function S(x, y) {
    a.disableAll(), y.isWebGL2 && a.enable(0), y.supportsVertexTextures && a.enable(1), y.instancing && a.enable(2), y.instancingColor && a.enable(3), y.matcap && a.enable(4), y.envMap && a.enable(5), y.normalMapObjectSpace && a.enable(6), y.normalMapTangentSpace && a.enable(7), y.clearcoat && a.enable(8), y.iridescence && a.enable(9), y.alphaTest && a.enable(10), y.vertexColors && a.enable(11), y.vertexAlphas && a.enable(12), y.vertexUv1s && a.enable(13), y.vertexUv2s && a.enable(14), y.vertexUv3s && a.enable(15), y.vertexTangents && a.enable(16), y.anisotropy && a.enable(17), y.alphaHash && a.enable(18), y.batching && a.enable(19), x.push(a.mask), a.disableAll(), y.fog && a.enable(0), y.useFog && a.enable(1), y.flatShading && a.enable(2), y.logarithmicDepthBuffer && a.enable(3), y.skinning && a.enable(4), y.morphTargets && a.enable(5), y.morphNormals && a.enable(6), y.morphColors && a.enable(7), y.premultipliedAlpha && a.enable(8), y.shadowMapEnabled && a.enable(9), y.useLegacyLights && a.enable(10), y.doubleSided && a.enable(11), y.flipSided && a.enable(12), y.useDepthPacking && a.enable(13), y.dithering && a.enable(14), y.transmission && a.enable(15), y.sheen && a.enable(16), y.opaque && a.enable(17), y.pointsUvs && a.enable(18), y.decodeVideoTexture && a.enable(19), x.push(a.mask);
  }
  function R(x) {
    const y = g[x.type];
    let z;
    if (y) {
      const Z = Gt[y];
      z = hc.clone(Z.uniforms);
    } else
      z = x.uniforms;
    return z;
  }
  function D(x, y) {
    let z;
    for (let Z = 0, re = c.length; Z < re; Z++) {
      const L = c[Z];
      if (L.cacheKey === y) {
        z = L, ++z.usedTimes;
        break;
      }
    }
    return z === void 0 && (z = new Af(i, y, x, s), c.push(z)), z;
  }
  function C(x) {
    if (--x.usedTimes === 0) {
      const y = c.indexOf(x);
      c[y] = c[c.length - 1], c.pop(), x.destroy();
    }
  }
  function A(x) {
    l.remove(x);
  }
  function W() {
    l.dispose();
  }
  return {
    getParameters: f,
    getProgramCacheKey: u,
    getUniforms: R,
    acquireProgram: D,
    releaseProgram: C,
    releaseShaderCache: A,
    // Exposed for resource monitoring & error feedback via renderer.info:
    programs: c,
    dispose: W
  };
}
function Pf() {
  let i = /* @__PURE__ */ new WeakMap();
  function e(s) {
    let o = i.get(s);
    return o === void 0 && (o = {}, i.set(s, o)), o;
  }
  function t(s) {
    i.delete(s);
  }
  function n(s, o, a) {
    i.get(s)[o] = a;
  }
  function r() {
    i = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    remove: t,
    update: n,
    dispose: r
  };
}
function Df(i, e) {
  return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.material.id !== e.material.id ? i.material.id - e.material.id : i.z !== e.z ? i.z - e.z : i.id - e.id;
}
function Ba(i, e) {
  return i.groupOrder !== e.groupOrder ? i.groupOrder - e.groupOrder : i.renderOrder !== e.renderOrder ? i.renderOrder - e.renderOrder : i.z !== e.z ? e.z - i.z : i.id - e.id;
}
function za() {
  const i = [];
  let e = 0;
  const t = [], n = [], r = [];
  function s() {
    e = 0, t.length = 0, n.length = 0, r.length = 0;
  }
  function o(d, p, m, g, v, f) {
    let u = i[e];
    return u === void 0 ? (u = {
      id: d.id,
      object: d,
      geometry: p,
      material: m,
      groupOrder: g,
      renderOrder: d.renderOrder,
      z: v,
      group: f
    }, i[e] = u) : (u.id = d.id, u.object = d, u.geometry = p, u.material = m, u.groupOrder = g, u.renderOrder = d.renderOrder, u.z = v, u.group = f), e++, u;
  }
  function a(d, p, m, g, v, f) {
    const u = o(d, p, m, g, v, f);
    m.transmission > 0 ? n.push(u) : m.transparent === !0 ? r.push(u) : t.push(u);
  }
  function l(d, p, m, g, v, f) {
    const u = o(d, p, m, g, v, f);
    m.transmission > 0 ? n.unshift(u) : m.transparent === !0 ? r.unshift(u) : t.unshift(u);
  }
  function c(d, p) {
    t.length > 1 && t.sort(d || Df), n.length > 1 && n.sort(p || Ba), r.length > 1 && r.sort(p || Ba);
  }
  function h() {
    for (let d = e, p = i.length; d < p; d++) {
      const m = i[d];
      if (m.id === null) break;
      m.id = null, m.object = null, m.geometry = null, m.material = null, m.group = null;
    }
  }
  return {
    opaque: t,
    transmissive: n,
    transparent: r,
    init: s,
    push: a,
    unshift: l,
    finish: h,
    sort: c
  };
}
function Uf() {
  let i = /* @__PURE__ */ new WeakMap();
  function e(n, r) {
    const s = i.get(n);
    let o;
    return s === void 0 ? (o = new za(), i.set(n, [o])) : r >= s.length ? (o = new za(), s.push(o)) : o = s[r], o;
  }
  function t() {
    i = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: e,
    dispose: t
  };
}
function If() {
  const i = {};
  return {
    get: function(e) {
      if (i[e.id] !== void 0)
        return i[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            direction: new P(),
            color: new Xe()
          };
          break;
        case "SpotLight":
          t = {
            position: new P(),
            direction: new P(),
            color: new Xe(),
            distance: 0,
            coneCos: 0,
            penumbraCos: 0,
            decay: 0
          };
          break;
        case "PointLight":
          t = {
            position: new P(),
            color: new Xe(),
            distance: 0,
            decay: 0
          };
          break;
        case "HemisphereLight":
          t = {
            direction: new P(),
            skyColor: new Xe(),
            groundColor: new Xe()
          };
          break;
        case "RectAreaLight":
          t = {
            color: new Xe(),
            position: new P(),
            halfWidth: new P(),
            halfHeight: new P()
          };
          break;
      }
      return i[e.id] = t, t;
    }
  };
}
function Nf() {
  const i = {};
  return {
    get: function(e) {
      if (i[e.id] !== void 0)
        return i[e.id];
      let t;
      switch (e.type) {
        case "DirectionalLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new Ie()
          };
          break;
        case "SpotLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new Ie()
          };
          break;
        case "PointLight":
          t = {
            shadowBias: 0,
            shadowNormalBias: 0,
            shadowRadius: 1,
            shadowMapSize: new Ie(),
            shadowCameraNear: 1,
            shadowCameraFar: 1e3
          };
          break;
      }
      return i[e.id] = t, t;
    }
  };
}
let Ff = 0;
function Of(i, e) {
  return (e.castShadow ? 2 : 0) - (i.castShadow ? 2 : 0) + (e.map ? 1 : 0) - (i.map ? 1 : 0);
}
function Bf(i, e) {
  const t = new If(), n = Nf(), 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 h = 0; h < 9; h++) r.probe.push(new P());
  const s = new P(), o = new Qe(), a = new Qe();
  function l(h, d) {
    let p = 0, m = 0, g = 0;
    for (let Z = 0; Z < 9; Z++) r.probe[Z].set(0, 0, 0);
    let v = 0, f = 0, u = 0, b = 0, S = 0, R = 0, D = 0, C = 0, A = 0, W = 0, x = 0;
    h.sort(Of);
    const y = d === !0 ? Math.PI : 1;
    for (let Z = 0, re = h.length; Z < re; Z++) {
      const L = h[Z], F = L.color, V = L.intensity, Y = L.distance, X = L.shadow && L.shadow.map ? L.shadow.map.texture : null;
      if (L.isAmbientLight)
        p += F.r * V * y, m += F.g * V * y, g += F.b * V * y;
      else if (L.isLightProbe) {
        for (let k = 0; k < 9; k++)
          r.probe[k].addScaledVector(L.sh.coefficients[k], V);
        x++;
      } else if (L.isDirectionalLight) {
        const k = t.get(L);
        if (k.color.copy(L.color).multiplyScalar(L.intensity * y), L.castShadow) {
          const q = L.shadow, Q = n.get(L);
          Q.shadowBias = q.bias, Q.shadowNormalBias = q.normalBias, Q.shadowRadius = q.radius, Q.shadowMapSize = q.mapSize, r.directionalShadow[v] = Q, r.directionalShadowMap[v] = X, r.directionalShadowMatrix[v] = L.shadow.matrix, R++;
        }
        r.directional[v] = k, v++;
      } else if (L.isSpotLight) {
        const k = t.get(L);
        k.position.setFromMatrixPosition(L.matrixWorld), k.color.copy(F).multiplyScalar(V * y), k.distance = Y, k.coneCos = Math.cos(L.angle), k.penumbraCos = Math.cos(L.angle * (1 - L.penumbra)), k.decay = L.decay, r.spot[u] = k;
        const q = L.shadow;
        if (L.map && (r.spotLightMap[A] = L.map, A++, q.updateMatrices(L), L.castShadow && W++), r.spotLightMatrix[u] = q.matrix, L.castShadow) {
          const Q = n.get(L);
          Q.shadowBias = q.bias, Q.shadowNormalBias = q.normalBias, Q.shadowRadius = q.radius, Q.shadowMapSize = q.mapSize, r.spotShadow[u] = Q, r.spotShadowMap[u] = X, C++;
        }
        u++;
      } else if (L.isRectAreaLight) {
        const k = t.get(L);
        k.color.copy(F).multiplyScalar(V), k.halfWidth.set(L.width * 0.5, 0, 0), k.halfHeight.set(0, L.height * 0.5, 0), r.rectArea[b] = k, b++;
      } else if (L.isPointLight) {
        const k = t.get(L);
        if (k.color.copy(L.color).multiplyScalar(L.intensity * y), k.distance = L.distance, k.decay = L.decay, L.castShadow) {
          const q = L.shadow, Q = n.get(L);
          Q.shadowBias = q.bias, Q.shadowNormalBias = q.normalBias, Q.shadowRadius = q.radius, Q.shadowMapSize = q.mapSize, Q.shadowCameraNear = q.camera.near, Q.shadowCameraFar = q.camera.far, r.pointShadow[f] = Q, r.pointShadowMap[f] = X, r.pointShadowMatrix[f] = L.shadow.matrix, D++;
        }
        r.point[f] = k, f++;
      } else if (L.isHemisphereLight) {
        const k = t.get(L);
        k.skyColor.copy(L.color).multiplyScalar(V * y), k.groundColor.copy(L.groundColor).multiplyScalar(V * y), r.hemi[S] = k, S++;
      }
    }
    b > 0 && (e.isWebGL2 ? i.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = se.LTC_FLOAT_1, r.rectAreaLTC2 = se.LTC_FLOAT_2) : (r.rectAreaLTC1 = se.LTC_HALF_1, r.rectAreaLTC2 = se.LTC_HALF_2) : i.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = se.LTC_FLOAT_1, r.rectAreaLTC2 = se.LTC_FLOAT_2) : i.has("OES_texture_half_float_linear") === !0 ? (r.rectAreaLTC1 = se.LTC_HALF_1, r.rectAreaLTC2 = se.LTC_HALF_2) : console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")), r.ambient[0] = p, r.ambient[1] = m, r.ambient[2] = g;
    const z = r.hash;
    (z.directionalLength !== v || z.pointLength !== f || z.spotLength !== u || z.rectAreaLength !== b || z.hemiLength !== S || z.numDirectionalShadows !== R || z.numPointShadows !== D || z.numSpotShadows !== C || z.numSpotMaps !== A || z.numLightProbes !== x) && (r.directional.length = v, r.spot.length = u, r.rectArea.length = b, r.point.length = f, r.hemi.length = S, r.directionalShadow.length = R, r.directionalShadowMap.length = R, r.pointShadow.length = D, r.pointShadowMap.length = D, r.spotShadow.length = C, r.spotShadowMap.length = C, r.directionalShadowMatrix.length = R, r.pointShadowMatrix.length = D, r.spotLightMatrix.length = C + A - W, r.spotLightMap.length = A, r.numSpotLightShadowsWithMaps = W, r.numLightProbes = x, z.directionalLength = v, z.pointLength = f, z.spotLength = u, z.rectAreaLength = b, z.hemiLength = S, z.numDirectionalShadows = R, z.numPointShadows = D, z.numSpotShadows = C, z.numSpotMaps = A, z.numLightProbes = x, r.version = Ff++);
  }
  function c(h, d) {
    let p = 0, m = 0, g = 0, v = 0, f = 0;
    const u = d.matrixWorldInverse;
    for (let b = 0, S = h.length; b < S; b++) {
      const R = h[b];
      if (R.isDirectionalLight) {
        const D = r.directional[p];
        D.direction.setFromMatrixPosition(R.matrixWorld), s.setFromMatrixPosition(R.target.matrixWorld), D.direction.sub(s), D.direction.transformDirection(u), p++;
      } else if (R.isSpotLight) {
        const D = r.spot[g];
        D.position.setFromMatrixPosition(R.matrixWorld), D.position.applyMatrix4(u), D.direction.setFromMatrixPosition(R.matrixWorld), s.setFromMatrixPosition(R.target.matrixWorld), D.direction.sub(s), D.direction.transformDirection(u), g++;
      } else if (R.isRectAreaLight) {
        const D = r.rectArea[v];
        D.position.setFromMatrixPosition(R.matrixWorld), D.position.applyMatrix4(u), a.identity(), o.copy(R.matrixWorld), o.premultiply(u), a.extractRotation(o), D.halfWidth.set(R.width * 0.5, 0, 0), D.halfHeight.set(0, R.height * 0.5, 0), D.halfWidth.applyMatrix4(a), D.halfHeight.applyMatrix4(a), v++;
      } else if (R.isPointLight) {
        const D = r.point[m];
        D.position.setFromMatrixPosition(R.matrixWorld), D.position.applyMatrix4(u), m++;
      } else if (R.isHemisphereLight) {
        const D = r.hemi[f];
        D.direction.setFromMatrixPosition(R.matrixWorld), D.direction.transformDirection(u), f++;
      }
    }
  }
  return {
    setup: l,
    setupView: c,
    state: r
  };
}
function Ga(i, e) {
  const t = new Bf(i, e), n = [], r = [];
  function s() {
    n.length = 0, r.length = 0;
  }
  function o(d) {
    n.push(d);
  }
  function a(d) {
    r.push(d);
  }
  function l(d) {
    t.setup(n, d);
  }
  function c(d) {
    t.setupView(n, d);
  }
  return {
    init: s,
    state: {
      lightsArray: n,
      shadowsArray: r,
      lights: t
    },
    setupLights: l,
    setupLightsView: c,
    pushLight: o,
    pushShadow: a
  };
}
function zf(i, e) {
  let t = /* @__PURE__ */ new WeakMap();
  function n(s, o = 0) {
    const a = t.get(s);
    let l;
    return a === void 0 ? (l = new Ga(i, e), t.set(s, [l])) : o >= a.length ? (l = new Ga(i, e), a.push(l)) : l = a[o], l;
  }
  function r() {
    t = /* @__PURE__ */ new WeakMap();
  }
  return {
    get: n,
    dispose: r
  };
}
class Gf extends Mi {
  constructor(e) {
    super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = Nl, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e);
  }
  copy(e) {
    return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this;
  }
}
class Hf extends Mi {
  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;
  }
}
const Vf = `void main() {
	gl_Position = vec4( position, 1.0 );
}`, kf = `uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;
function Wf(i, e, t) {
  let n = new cs();
  const r = new Ie(), s = new Ie(), o = new $e(), a = new Gf({ depthPacking: Fl }), l = new Hf(), c = {}, h = t.maxTextureSize, d = { [un]: Mt, [Mt]: un, [Kt]: Kt }, p = new wn({
    defines: {
      VSM_SAMPLES: 8
    },
    uniforms: {
      shadow_pass: { value: null },
      resolution: { value: new Ie() },
      radius: { value: 4 }
    },
    vertexShader: Vf,
    fragmentShader: kf
  }), m = p.clone();
  m.defines.HORIZONTAL_PASS = 1;
  const g = new hn();
  g.setAttribute(
    "position",
    new Bt(
      new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]),
      3
    )
  );
  const v = new Ot(g, p), f = this;
  this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = so;
  let u = this.type;
  this.render = function(C, A, W) {
    if (f.enabled === !1 || f.autoUpdate === !1 && f.needsUpdate === !1 || C.length === 0) return;
    const x = i.getRenderTarget(), y = i.getActiveCubeFace(), z = i.getActiveMipmapLevel(), Z = i.state;
    Z.setBlending(on), Z.buffers.color.setClear(1, 1, 1, 1), Z.buffers.depth.setTest(!0), Z.setScissorTest(!1);
    const re = u !== jt && this.type === jt, L = u === jt && this.type !== jt;
    for (let F = 0, V = C.length; F < V; F++) {
      const Y = C[F], X = Y.shadow;
      if (X === void 0) {
        console.warn("THREE.WebGLShadowMap:", Y, "has no shadow.");
        continue;
      }
      if (X.autoUpdate === !1 && X.needsUpdate === !1) continue;
      r.copy(X.mapSize);
      const k = X.getFrameExtents();
      if (r.multiply(k), s.copy(X.mapSize), (r.x > h || r.y > h) && (r.x > h && (s.x = Math.floor(h / k.x), r.x = s.x * k.x, X.mapSize.x = s.x), r.y > h && (s.y = Math.floor(h / k.y), r.y = s.y * k.y, X.mapSize.y = s.y)), X.map === null || re === !0 || L === !0) {
        const Q = this.type !== jt ? { minFilter: gt, magFilter: gt } : {};
        X.map !== null && X.map.dispose(), X.map = new bn(r.x, r.y, Q), X.map.texture.name = Y.name + ".shadowMap", X.camera.updateProjectionMatrix();
      }
      i.setRenderTarget(X.map), i.clear();
      const q = X.getViewportCount();
      for (let Q = 0; Q < q; Q++) {
        const ce = X.getViewport(Q);
        o.set(
          s.x * ce.x,
          s.y * ce.y,
          s.x * ce.z,
          s.y * ce.w
        ), Z.viewport(o), X.updateMatrices(Y, Q), n = X.getFrustum(), R(A, W, X.camera, Y, this.type);
      }
      X.isPointLightShadow !== !0 && this.type === jt && b(X, W), X.needsUpdate = !1;
    }
    u = this.type, f.needsUpdate = !1, i.setRenderTarget(x, y, z);
  };
  function b(C, A) {
    const W = e.update(v);
    p.defines.VSM_SAMPLES !== C.blurSamples && (p.defines.VSM_SAMPLES = C.blurSamples, m.defines.VSM_SAMPLES = C.blurSamples, p.needsUpdate = !0, m.needsUpdate = !0), C.mapPass === null && (C.mapPass = new bn(r.x, r.y)), p.uniforms.shadow_pass.value = C.map.texture, p.uniforms.resolution.value = C.mapSize, p.uniforms.radius.value = C.radius, i.setRenderTarget(C.mapPass), i.clear(), i.renderBufferDirect(A, null, W, p, v, null), m.uniforms.shadow_pass.value = C.mapPass.texture, m.uniforms.resolution.value = C.mapSize, m.uniforms.radius.value = C.radius, i.setRenderTarget(C.map), i.clear(), i.renderBufferDirect(A, null, W, m, v, null);
  }
  function S(C, A, W, x) {
    let y = null;
    const z = W.isPointLight === !0 ? C.customDistanceMaterial : C.customDepthMaterial;
    if (z !== void 0)
      y = z;
    else if (y = W.isPointLight === !0 ? l : a, i.localClippingEnabled && A.clipShadows === !0 && Array.isArray(A.clippingPlanes) && A.clippingPlanes.length !== 0 || A.displacementMap && A.displacementScale !== 0 || A.alphaMap && A.alphaTest > 0 || A.map && A.alphaTest > 0) {
      const Z = y.uuid, re = A.uuid;
      let L = c[Z];
      L === void 0 && (L = {}, c[Z] = L);
      let F = L[re];
      F === void 0 && (F = y.clone(), L[re] = F, A.addEventListener("dispose", D)), y = F;
    }
    if (y.visible = A.visible, y.wireframe = A.wireframe, x === jt ? y.side = A.shadowSide !== null ? A.shadowSide : A.side : y.side = A.shadowSide !== null ? A.shadowSide : d[A.side], y.alphaMap = A.alphaMap, y.alphaTest = A.alphaTest, y.map = A.map, y.clipShadows = A.clipShadows, y.clippingPlanes = A.clippingPlanes, y.clipIntersection = A.clipIntersection, y.displacementMap = A.displacementMap, y.displacementScale = A.displacementScale, y.displacementBias = A.displacementBias, y.wireframeLinewidth = A.wireframeLinewidth, y.linewidth = A.linewidth, W.isPointLight === !0 && y.isMeshDistanceMaterial === !0) {
      const Z = i.properties.get(y);
      Z.light = W;
    }
    return y;
  }
  function R(C, A, W, x, y) {
    if (C.visible === !1) return;
    if (C.layers.test(A.layers) && (C.isMesh || C.isLine || C.isPoints) && (C.castShadow || C.receiveShadow && y === jt) && (!C.frustumCulled || n.intersectsObject(C))) {
      C.modelViewMatrix.multiplyMatrices(W.matrixWorldInverse, C.matrixWorld);
      const re = e.update(C), L = C.material;
      if (Array.isArray(L)) {
        const F = re.groups;
        for (let V = 0, Y = F.length; V < Y; V++) {
          const X = F[V], k = L[X.materialIndex];
          if (k && k.visible) {
            const q = S(C, k, x, y);
            C.onBeforeShadow(i, C, A, W, re, q, X), i.renderBufferDirect(W, null, re, q, C, X), C.onAfterShadow(i, C, A, W, re, q, X);
          }
        }
      } else if (L.visible) {
        const F = S(C, L, x, y);
        C.onBeforeShadow(i, C, A, W, re, F, null), i.renderBufferDirect(W, null, re, F, C, null), C.onAfterShadow(i, C, A, W, re, F, null);
      }
    }
    const Z = C.children;
    for (let re = 0, L = Z.length; re < L; re++)
      R(Z[re], A, W, x, y);
  }
  function D(C) {
    C.target.removeEventListener("dispose", D);
    for (const W in c) {
      const x = c[W], y = C.target.uuid;
      y in x && (x[y].dispose(), delete x[y]);
    }
  }
}
function Xf(i, e, t) {
  const n = t.isWebGL2;
  function r() {
    let w = !1;
    const ie = new $e();
    let le = null;
    const Ce = new $e(0, 0, 0, 0);
    return {
      setMask: function(Te) {
        le !== Te && !w && (i.colorMask(Te, Te, Te, Te), le = Te);
      },
      setLocked: function(Te) {
        w = Te;
      },
      setClear: function(Te, ke, We, et, nt) {
        nt === !0 && (Te *= et, ke *= et, We *= et), ie.set(Te, ke, We, et), Ce.equals(ie) === !1 && (i.clearColor(Te, ke, We, et), Ce.copy(ie));
      },
      reset: function() {
        w = !1, le = null, Ce.set(-1, 0, 0, 0);
      }
    };
  }
  function s() {
    let w = !1, ie = null, le = null, Ce = null;
    return {
      setTest: function(Te) {
        Te ? Ae(i.DEPTH_TEST) : ge(i.DEPTH_TEST);
      },
      setMask: function(Te) {
        ie !== Te && !w && (i.depthMask(Te), ie = Te);
      },
      setFunc: function(Te) {
        if (le !== Te) {
          switch (Te) {
            case hl:
              i.depthFunc(i.NEVER);
              break;
            case dl:
              i.depthFunc(i.ALWAYS);
              break;
            case fl:
              i.depthFunc(i.LESS);
              break;
            case $i:
              i.depthFunc(i.LEQUAL);
              break;
            case pl:
              i.depthFunc(i.EQUAL);
              break;
            case ml:
              i.depthFunc(i.GEQUAL);
              break;
            case _l:
              i.depthFunc(i.GREATER);
              break;
            case gl:
              i.depthFunc(i.NOTEQUAL);
              break;
            default:
              i.depthFunc(i.LEQUAL);
          }
          le = Te;
        }
      },
      setLocked: function(Te) {
        w = Te;
      },
      setClear: function(Te) {
        Ce !== Te && (i.clearDepth(Te), Ce = Te);
      },
      reset: function() {
        w = !1, ie = null, le = null, Ce = null;
      }
    };
  }
  function o() {
    let w = !1, ie = null, le = null, Ce = null, Te = null, ke = null, We = null, et = null, nt = null;
    return {
      setTest: function(qe) {
        w || (qe ? Ae(i.STENCIL_TEST) : ge(i.STENCIL_TEST));
      },
      setMask: function(qe) {
        ie !== qe && !w && (i.stencilMask(qe), ie = qe);
      },
      setFunc: function(qe, st, zt) {
        (le !== qe || Ce !== st || Te !== zt) && (i.stencilFunc(qe, st, zt), le = qe, Ce = st, Te = zt);
      },
      setOp: function(qe, st, zt) {
        (ke !== qe || We !== st || et !== zt) && (i.stencilOp(qe, st, zt), ke = qe, We = st, et = zt);
      },
      setLocked: function(qe) {
        w = qe;
      },
      setClear: function(qe) {
        nt !== qe && (i.clearStencil(qe), nt = qe);
      },
      reset: function() {
        w = !1, ie = null, le = null, Ce = null, Te = null, ke = null, We = null, et = null, nt = null;
      }
    };
  }
  const a = new r(), l = new s(), c = new o(), h = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap();
  let p = {}, m = {}, g = /* @__PURE__ */ new WeakMap(), v = [], f = null, u = !1, b = null, S = null, R = null, D = null, C = null, A = null, W = null, x = new Xe(0, 0, 0), y = 0, z = !1, Z = null, re = null, L = null, F = null, V = null;
  const Y = i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  let X = !1, k = 0;
  const q = i.getParameter(i.VERSION);
  q.indexOf("WebGL") !== -1 ? (k = parseFloat(/^WebGL (\d)/.exec(q)[1]), X = k >= 1) : q.indexOf("OpenGL ES") !== -1 && (k = parseFloat(/^OpenGL ES (\d)/.exec(q)[1]), X = k >= 2);
  let Q = null, ce = {};
  const H = i.getParameter(i.SCISSOR_BOX), j = i.getParameter(i.VIEWPORT), oe = new $e().fromArray(H), ve = new $e().fromArray(j);
  function _e(w, ie, le, Ce) {
    const Te = new Uint8Array(4), ke = i.createTexture();
    i.bindTexture(w, ke), i.texParameteri(w, i.TEXTURE_MIN_FILTER, i.NEAREST), i.texParameteri(w, i.TEXTURE_MAG_FILTER, i.NEAREST);
    for (let We = 0; We < le; We++)
      n && (w === i.TEXTURE_3D || w === i.TEXTURE_2D_ARRAY) ? i.texImage3D(ie, 0, i.RGBA, 1, 1, Ce, 0, i.RGBA, i.UNSIGNED_BYTE, Te) : i.texImage2D(ie + We, 0, i.RGBA, 1, 1, 0, i.RGBA, i.UNSIGNED_BYTE, Te);
    return ke;
  }
  const we = {};
  we[i.TEXTURE_2D] = _e(i.TEXTURE_2D, i.TEXTURE_2D, 1), we[i.TEXTURE_CUBE_MAP] = _e(i.TEXTURE_CUBE_MAP, i.TEXTURE_CUBE_MAP_POSITIVE_X, 6), n && (we[i.TEXTURE_2D_ARRAY] = _e(i.TEXTURE_2D_ARRAY, i.TEXTURE_2D_ARRAY, 1, 1), we[i.TEXTURE_3D] = _e(i.TEXTURE_3D, i.TEXTURE_3D, 1, 1)), a.setClear(0, 0, 0, 1), l.setClear(1), c.setClear(0), Ae(i.DEPTH_TEST), l.setFunc($i), be(!1), M(Ss), Ae(i.CULL_FACE), pe(on);
  function Ae(w) {
    p[w] !== !0 && (i.enable(w), p[w] = !0);
  }
  function ge(w) {
    p[w] !== !1 && (i.disable(w), p[w] = !1);
  }
  function Pe(w, ie) {
    return m[w] !== ie ? (i.bindFramebuffer(w, ie), m[w] = ie, n && (w === i.DRAW_FRAMEBUFFER && (m[i.FRAMEBUFFER] = ie), w === i.FRAMEBUFFER && (m[i.DRAW_FRAMEBUFFER] = ie)), !0) : !1;
  }
  function N(w, ie) {
    let le = v, Ce = !1;
    if (w)
      if (le = g.get(ie), le === void 0 && (le = [], g.set(ie, le)), w.isWebGLMultipleRenderTargets) {
        const Te = w.texture;
        if (le.length !== Te.length || le[0] !== i.COLOR_ATTACHMENT0) {
          for (let ke = 0, We = Te.length; ke < We; ke++)
            le[ke] = i.COLOR_ATTACHMENT0 + ke;
          le.length = Te.length, Ce = !0;
        }
      } else
        le[0] !== i.COLOR_ATTACHMENT0 && (le[0] = i.COLOR_ATTACHMENT0, Ce = !0);
    else
      le[0] !== i.BACK && (le[0] = i.BACK, Ce = !0);
    Ce && (t.isWebGL2 ? i.drawBuffers(le) : e.get("WEBGL_draw_buffers").drawBuffersWEBGL(le));
  }
  function rt(w) {
    return f !== w ? (i.useProgram(w), f = w, !0) : !1;
  }
  const Me = {
    [Mn]: i.FUNC_ADD,
    [Zo]: i.FUNC_SUBTRACT,
    [$o]: i.FUNC_REVERSE_SUBTRACT
  };
  if (n)
    Me[bs] = i.MIN, Me[As] = i.MAX;
  else {
    const w = e.get("EXT_blend_minmax");
    w !== null && (Me[bs] = w.MIN_EXT, Me[As] = w.MAX_EXT);
  }
  const Re = {
    [Jo]: i.ZERO,
    [Qo]: i.ONE,
    [el]: i.SRC_COLOR,
    [Kr]: i.SRC_ALPHA,
    [al]: i.SRC_ALPHA_SATURATE,
    [rl]: i.DST_COLOR,
    [nl]: i.DST_ALPHA,
    [tl]: i.ONE_MINUS_SRC_COLOR,
    [Zr]: i.ONE_MINUS_SRC_ALPHA,
    [sl]: i.ONE_MINUS_DST_COLOR,
    [il]: i.ONE_MINUS_DST_ALPHA,
    [ol]: i.CONSTANT_COLOR,
    [ll]: i.ONE_MINUS_CONSTANT_COLOR,
    [cl]: i.CONSTANT_ALPHA,
    [ul]: i.ONE_MINUS_CONSTANT_ALPHA
  };
  function pe(w, ie, le, Ce, Te, ke, We, et, nt, qe) {
    if (w === on) {
      u === !0 && (ge(i.BLEND), u = !1);
      return;
    }
    if (u === !1 && (Ae(i.BLEND), u = !0), w !== Ko) {
      if (w !== b || qe !== z) {
        if ((S !== Mn || C !== Mn) && (i.blendEquation(i.FUNC_ADD), S = Mn, C = Mn), qe)
          switch (w) {
            case $n:
              i.blendFuncSeparate(i.ONE, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);
              break;
            case Es:
              i.blendFunc(i.ONE, i.ONE);
              break;
            case ys:
              i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);
              break;
            case Ts:
              i.blendFuncSeparate(i.ZERO, i.SRC_COLOR, i.ZERO, i.SRC_ALPHA);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", w);
              break;
          }
        else
          switch (w) {
            case $n:
              i.blendFuncSeparate(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA, i.ONE, i.ONE_MINUS_SRC_ALPHA);
              break;
            case Es:
              i.blendFunc(i.SRC_ALPHA, i.ONE);
              break;
            case ys:
              i.blendFuncSeparate(i.ZERO, i.ONE_MINUS_SRC_COLOR, i.ZERO, i.ONE);
              break;
            case Ts:
              i.blendFunc(i.ZERO, i.SRC_COLOR);
              break;
            default:
              console.error("THREE.WebGLState: Invalid blending: ", w);
              break;
          }
        R = null, D = null, A = null, W = null, x.set(0, 0, 0), y = 0, b = w, z = qe;
      }
      return;
    }
    Te = Te || ie, ke = ke || le, We = We || Ce, (ie !== S || Te !== C) && (i.blendEquationSeparate(Me[ie], Me[Te]), S = ie, C = Te), (le !== R || Ce !== D || ke !== A || We !== W) && (i.blendFuncSeparate(Re[le], Re[Ce], Re[ke], Re[We]), R = le, D = Ce, A = ke, W = We), (et.equals(x) === !1 || nt !== y) && (i.blendColor(et.r, et.g, et.b, nt), x.copy(et), y = nt), b = w, z = !1;
  }
  function je(w, ie) {
    w.side === Kt ? ge(i.CULL_FACE) : Ae(i.CULL_FACE);
    let le = w.side === Mt;
    ie && (le = !le), be(le), w.blending === $n && w.transparent === !1 ? pe(on) : pe(w.blending, w.blendEquation, w.blendSrc, w.blendDst, w.blendEquationAlpha, w.blendSrcAlpha, w.blendDstAlpha, w.blendColor, w.blendAlpha, w.premultipliedAlpha), l.setFunc(w.depthFunc), l.setTest(w.depthTest), l.setMask(w.depthWrite), a.setMask(w.colorWrite);
    const Ce = w.stencilWrite;
    c.setTest(Ce), Ce && (c.setMask(w.stencilWriteMask), c.setFunc(w.stencilFunc, w.stencilRef, w.stencilFuncMask), c.setOp(w.stencilFail, w.stencilZFail, w.stencilZPass)), I(w.polygonOffset, w.polygonOffsetFactor, w.polygonOffsetUnits), w.alphaToCoverage === !0 ? Ae(i.SAMPLE_ALPHA_TO_COVERAGE) : ge(i.SAMPLE_ALPHA_TO_COVERAGE);
  }
  function be(w) {
    Z !== w && (w ? i.frontFace(i.CW) : i.frontFace(i.CCW), Z = w);
  }
  function M(w) {
    w !== Yo ? (Ae(i.CULL_FACE), w !== re && (w === Ss ? i.cullFace(i.BACK) : w === jo ? i.cullFace(i.FRONT) : i.cullFace(i.FRONT_AND_BACK))) : ge(i.CULL_FACE), re = w;
  }
  function _(w) {
    w !== L && (X && i.lineWidth(w), L = w);
  }
  function I(w, ie, le) {
    w ? (Ae(i.POLYGON_OFFSET_FILL), (F !== ie || V !== le) && (i.polygonOffset(ie, le), F = ie, V = le)) : ge(i.POLYGON_OFFSET_FILL);
  }
  function $(w) {
    w ? Ae(i.SCISSOR_TEST) : ge(i.SCISSOR_TEST);
  }
  function K(w) {
    w === void 0 && (w = i.TEXTURE0 + Y - 1), Q !== w && (i.activeTexture(w), Q = w);
  }
  function J(w, ie, le) {
    le === void 0 && (Q === null ? le = i.TEXTURE0 + Y - 1 : le = Q);
    let Ce = ce[le];
    Ce === void 0 && (Ce = { type: void 0, texture: void 0 }, ce[le] = Ce), (Ce.type !== w || Ce.texture !== ie) && (Q !== le && (i.activeTexture(le), Q = le), i.bindTexture(w, ie || we[w]), Ce.type = w, Ce.texture = ie);
  }
  function me() {
    const w = ce[Q];
    w !== void 0 && w.type !== void 0 && (i.bindTexture(w.type, null), w.type = void 0, w.texture = void 0);
  }
  function ae() {
    try {
      i.compressedTexImage2D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function he() {
    try {
      i.compressedTexImage3D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function ye() {
    try {
      i.texSubImage2D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function Fe() {
    try {
      i.texSubImage3D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function ee() {
    try {
      i.compressedTexSubImage2D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function Ye() {
    try {
      i.compressedTexSubImage3D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function ze() {
    try {
      i.texStorage2D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function De() {
    try {
      i.texStorage3D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function Ee() {
    try {
      i.texImage2D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function ue() {
    try {
      i.texImage3D.apply(i, arguments);
    } catch (w) {
      console.error("THREE.WebGLState:", w);
    }
  }
  function T(w) {
    oe.equals(w) === !1 && (i.scissor(w.x, w.y, w.z, w.w), oe.copy(w));
  }
  function ne(w) {
    ve.equals(w) === !1 && (i.viewport(w.x, w.y, w.z, w.w), ve.copy(w));
  }
  function xe(w, ie) {
    let le = d.get(ie);
    le === void 0 && (le = /* @__PURE__ */ new WeakMap(), d.set(ie, le));
    let Ce = le.get(w);
    Ce === void 0 && (Ce = i.getUniformBlockIndex(ie, w.name), le.set(w, Ce));
  }
  function fe(w, ie) {
    const Ce = d.get(ie).get(w);
    h.get(ie) !== Ce && (i.uniformBlockBinding(ie, Ce, w.__bindingPointIndex), h.set(ie, Ce));
  }
  function te() {
    i.disable(i.BLEND), i.disable(i.CULL_FACE), i.disable(i.DEPTH_TEST), i.disable(i.POLYGON_OFFSET_FILL), i.disable(i.SCISSOR_TEST), i.disable(i.STENCIL_TEST), i.disable(i.SAMPLE_ALPHA_TO_COVERAGE), i.blendEquation(i.FUNC_ADD), i.blendFunc(i.ONE, i.ZERO), i.blendFuncSeparate(i.ONE, i.ZERO, i.ONE, i.ZERO), i.blendColor(0, 0, 0, 0), i.colorMask(!0, !0, !0, !0), i.clearColor(0, 0, 0, 0), i.depthMask(!0), i.depthFunc(i.LESS), i.clearDepth(1), i.stencilMask(4294967295), i.stencilFunc(i.ALWAYS, 0, 4294967295), i.stencilOp(i.KEEP, i.KEEP, i.KEEP), i.clearStencil(0), i.cullFace(i.BACK), i.frontFace(i.CCW), i.polygonOffset(0, 0), i.activeTexture(i.TEXTURE0), i.bindFramebuffer(i.FRAMEBUFFER, null), n === !0 && (i.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), i.bindFramebuffer(i.READ_FRAMEBUFFER, null)), i.useProgram(null), i.lineWidth(1), i.scissor(0, 0, i.canvas.width, i.canvas.height), i.viewport(0, 0, i.canvas.width, i.canvas.height), p = {}, Q = null, ce = {}, m = {}, g = /* @__PURE__ */ new WeakMap(), v = [], f = null, u = !1, b = null, S = null, R = null, D = null, C = null, A = null, W = null, x = new Xe(0, 0, 0), y = 0, z = !1, Z = null, re = null, L = null, F = null, V = null, oe.set(0, 0, i.canvas.width, i.canvas.height), ve.set(0, 0, i.canvas.width, i.canvas.height), a.reset(), l.reset(), c.reset();
  }
  return {
    buffers: {
      color: a,
      depth: l,
      stencil: c
    },
    enable: Ae,
    disable: ge,
    bindFramebuffer: Pe,
    drawBuffers: N,
    useProgram: rt,
    setBlending: pe,
    setMaterial: je,
    setFlipSided: be,
    setCullFace: M,
    setLineWidth: _,
    setPolygonOffset: I,
    setScissorTest: $,
    activeTexture: K,
    bindTexture: J,
    unbindTexture: me,
    compressedTexImage2D: ae,
    compressedTexImage3D: he,
    texImage2D: Ee,
    texImage3D: ue,
    updateUBOMapping: xe,
    uniformBlockBinding: fe,
    texStorage2D: ze,
    texStorage3D: De,
    texSubImage2D: ye,
    texSubImage3D: Fe,
    compressedTexSubImage2D: ee,
    compressedTexSubImage3D: Ye,
    scissor: T,
    viewport: ne,
    reset: te
  };
}
function qf(i, e, t, n, r, s, o) {
  const a = r.isWebGL2, l = e.has("WEBGL_multisampled_render_to_texture") ? e.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), h = /* @__PURE__ */ new WeakMap();
  let d;
  const p = /* @__PURE__ */ new WeakMap();
  let m = !1;
  try {
    m = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null;
  } catch {
  }
  function g(M, _) {
    return m ? (
      // eslint-disable-next-line compat/compat
      new OffscreenCanvas(M, _)
    ) : nr("canvas");
  }
  function v(M, _, I, $) {
    let K = 1;
    if ((M.width > $ || M.height > $) && (K = $ / Math.max(M.width, M.height)), K < 1 || _ === !0)
      if (typeof HTMLImageElement < "u" && M instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && M instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && M instanceof ImageBitmap) {
        const J = _ ? is : Math.floor, me = J(K * M.width), ae = J(K * M.height);
        d === void 0 && (d = g(me, ae));
        const he = I ? g(me, ae) : d;
        return he.width = me, he.height = ae, he.getContext("2d").drawImage(M, 0, 0, me, ae), console.warn("THREE.WebGLRenderer: Texture has been resized from (" + M.width + "x" + M.height + ") to (" + me + "x" + ae + ")."), he;
      } else
        return "data" in M && console.warn("THREE.WebGLRenderer: Image in DataTexture is too big (" + M.width + "x" + M.height + ")."), M;
    return M;
  }
  function f(M) {
    return na(M.width) && na(M.height);
  }
  function u(M) {
    return a ? !1 : M.wrapS !== Nt || M.wrapT !== Nt || M.minFilter !== gt && M.minFilter !== Rt;
  }
  function b(M, _) {
    return M.generateMipmaps && _ && M.minFilter !== gt && M.minFilter !== Rt;
  }
  function S(M) {
    i.generateMipmap(M);
  }
  function R(M, _, I, $, K = !1) {
    if (a === !1) return _;
    if (M !== null) {
      if (i[M] !== void 0) return i[M];
      console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '" + M + "'");
    }
    let J = _;
    if (_ === i.RED && (I === i.FLOAT && (J = i.R32F), I === i.HALF_FLOAT && (J = i.R16F), I === i.UNSIGNED_BYTE && (J = i.R8)), _ === i.RED_INTEGER && (I === i.UNSIGNED_BYTE && (J = i.R8UI), I === i.UNSIGNED_SHORT && (J = i.R16UI), I === i.UNSIGNED_INT && (J = i.R32UI), I === i.BYTE && (J = i.R8I), I === i.SHORT && (J = i.R16I), I === i.INT && (J = i.R32I)), _ === i.RG && (I === i.FLOAT && (J = i.RG32F), I === i.HALF_FLOAT && (J = i.RG16F), I === i.UNSIGNED_BYTE && (J = i.RG8)), _ === i.RGBA) {
      const me = K ? Ji : Ke.getTransfer($);
      I === i.FLOAT && (J = i.RGBA32F), I === i.HALF_FLOAT && (J = i.RGBA16F), I === i.UNSIGNED_BYTE && (J = me === Ze ? i.SRGB8_ALPHA8 : i.RGBA8), I === i.UNSIGNED_SHORT_4_4_4_4 && (J = i.RGBA4), I === i.UNSIGNED_SHORT_5_5_5_1 && (J = i.RGB5_A1);
    }
    return (J === i.R16F || J === i.R32F || J === i.RG16F || J === i.RG32F || J === i.RGBA16F || J === i.RGBA32F) && e.get("EXT_color_buffer_float"), J;
  }
  function D(M, _, I) {
    return b(M, I) === !0 || M.isFramebufferTexture && M.minFilter !== gt && M.minFilter !== Rt ? Math.log2(Math.max(_.width, _.height)) + 1 : M.mipmaps !== void 0 && M.mipmaps.length > 0 ? M.mipmaps.length : M.isCompressedTexture && Array.isArray(M.image) ? _.mipmaps.length : 1;
  }
  function C(M) {
    return M === gt || M === ws || M === pr ? i.NEAREST : i.LINEAR;
  }
  function A(M) {
    const _ = M.target;
    _.removeEventListener("dispose", A), x(_), _.isVideoTexture && h.delete(_);
  }
  function W(M) {
    const _ = M.target;
    _.removeEventListener("dispose", W), z(_);
  }
  function x(M) {
    const _ = n.get(M);
    if (_.__webglInit === void 0) return;
    const I = M.source, $ = p.get(I);
    if ($) {
      const K = $[_.__cacheKey];
      K.usedTimes--, K.usedTimes === 0 && y(M), Object.keys($).length === 0 && p.delete(I);
    }
    n.remove(M);
  }
  function y(M) {
    const _ = n.get(M);
    i.deleteTexture(_.__webglTexture);
    const I = M.source, $ = p.get(I);
    delete $[_.__cacheKey], o.memory.textures--;
  }
  function z(M) {
    const _ = M.texture, I = n.get(M), $ = n.get(_);
    if ($.__webglTexture !== void 0 && (i.deleteTexture($.__webglTexture), o.memory.textures--), M.depthTexture && M.depthTexture.dispose(), M.isWebGLCubeRenderTarget)
      for (let K = 0; K < 6; K++) {
        if (Array.isArray(I.__webglFramebuffer[K]))
          for (let J = 0; J < I.__webglFramebuffer[K].length; J++) i.deleteFramebuffer(I.__webglFramebuffer[K][J]);
        else
          i.deleteFramebuffer(I.__webglFramebuffer[K]);
        I.__webglDepthbuffer && i.deleteRenderbuffer(I.__webglDepthbuffer[K]);
      }
    else {
      if (Array.isArray(I.__webglFramebuffer))
        for (let K = 0; K < I.__webglFramebuffer.length; K++) i.deleteFramebuffer(I.__webglFramebuffer[K]);
      else
        i.deleteFramebuffer(I.__webglFramebuffer);
      if (I.__webglDepthbuffer && i.deleteRenderbuffer(I.__webglDepthbuffer), I.__webglMultisampledFramebuffer && i.deleteFramebuffer(I.__webglMultisampledFramebuffer), I.__webglColorRenderbuffer)
        for (let K = 0; K < I.__webglColorRenderbuffer.length; K++)
          I.__webglColorRenderbuffer[K] && i.deleteRenderbuffer(I.__webglColorRenderbuffer[K]);
      I.__webglDepthRenderbuffer && i.deleteRenderbuffer(I.__webglDepthRenderbuffer);
    }
    if (M.isWebGLMultipleRenderTargets)
      for (let K = 0, J = _.length; K < J; K++) {
        const me = n.get(_[K]);
        me.__webglTexture && (i.deleteTexture(me.__webglTexture), o.memory.textures--), n.remove(_[K]);
      }
    n.remove(_), n.remove(M);
  }
  let Z = 0;
  function re() {
    Z = 0;
  }
  function L() {
    const M = Z;
    return M >= r.maxTextures && console.warn("THREE.WebGLTextures: Trying to use " + M + " texture units while this GPU supports only " + r.maxTextures), Z += 1, M;
  }
  function F(M) {
    const _ = [];
    return _.push(M.wrapS), _.push(M.wrapT), _.push(M.wrapR || 0), _.push(M.magFilter), _.push(M.minFilter), _.push(M.anisotropy), _.push(M.internalFormat), _.push(M.format), _.push(M.type), _.push(M.generateMipmaps), _.push(M.premultiplyAlpha), _.push(M.flipY), _.push(M.unpackAlignment), _.push(M.colorSpace), _.join();
  }
  function V(M, _) {
    const I = n.get(M);
    if (M.isVideoTexture && je(M), M.isRenderTargetTexture === !1 && M.version > 0 && I.__version !== M.version) {
      const $ = M.image;
      if ($ === null)
        console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");
      else if ($.complete === !1)
        console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");
      else {
        oe(I, M, _);
        return;
      }
    }
    t.bindTexture(i.TEXTURE_2D, I.__webglTexture, i.TEXTURE0 + _);
  }
  function Y(M, _) {
    const I = n.get(M);
    if (M.version > 0 && I.__version !== M.version) {
      oe(I, M, _);
      return;
    }
    t.bindTexture(i.TEXTURE_2D_ARRAY, I.__webglTexture, i.TEXTURE0 + _);
  }
  function X(M, _) {
    const I = n.get(M);
    if (M.version > 0 && I.__version !== M.version) {
      oe(I, M, _);
      return;
    }
    t.bindTexture(i.TEXTURE_3D, I.__webglTexture, i.TEXTURE0 + _);
  }
  function k(M, _) {
    const I = n.get(M);
    if (M.version > 0 && I.__version !== M.version) {
      ve(I, M, _);
      return;
    }
    t.bindTexture(i.TEXTURE_CUBE_MAP, I.__webglTexture, i.TEXTURE0 + _);
  }
  const q = {
    [Qr]: i.REPEAT,
    [Nt]: i.CLAMP_TO_EDGE,
    [es]: i.MIRRORED_REPEAT
  }, Q = {
    [gt]: i.NEAREST,
    [ws]: i.NEAREST_MIPMAP_NEAREST,
    [pr]: i.NEAREST_MIPMAP_LINEAR,
    [Rt]: i.LINEAR,
    [Al]: i.LINEAR_MIPMAP_NEAREST,
    [_i]: i.LINEAR_MIPMAP_LINEAR
  }, ce = {
    [Bl]: i.NEVER,
    [Wl]: i.ALWAYS,
    [zl]: i.LESS,
    [xo]: i.LEQUAL,
    [Gl]: i.EQUAL,
    [kl]: i.GEQUAL,
    [Hl]: i.GREATER,
    [Vl]: i.NOTEQUAL
  };
  function H(M, _, I) {
    if (I ? (i.texParameteri(M, i.TEXTURE_WRAP_S, q[_.wrapS]), i.texParameteri(M, i.TEXTURE_WRAP_T, q[_.wrapT]), (M === i.TEXTURE_3D || M === i.TEXTURE_2D_ARRAY) && i.texParameteri(M, i.TEXTURE_WRAP_R, q[_.wrapR]), i.texParameteri(M, i.TEXTURE_MAG_FILTER, Q[_.magFilter]), i.texParameteri(M, i.TEXTURE_MIN_FILTER, Q[_.minFilter])) : (i.texParameteri(M, i.TEXTURE_WRAP_S, i.CLAMP_TO_EDGE), i.texParameteri(M, i.TEXTURE_WRAP_T, i.CLAMP_TO_EDGE), (M === i.TEXTURE_3D || M === i.TEXTURE_2D_ARRAY) && i.texParameteri(M, i.TEXTURE_WRAP_R, i.CLAMP_TO_EDGE), (_.wrapS !== Nt || _.wrapT !== Nt) && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."), i.texParameteri(M, i.TEXTURE_MAG_FILTER, C(_.magFilter)), i.texParameteri(M, i.TEXTURE_MIN_FILTER, C(_.minFilter)), _.minFilter !== gt && _.minFilter !== Rt && console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")), _.compareFunction && (i.texParameteri(M, i.TEXTURE_COMPARE_MODE, i.COMPARE_REF_TO_TEXTURE), i.texParameteri(M, i.TEXTURE_COMPARE_FUNC, ce[_.compareFunction])), e.has("EXT_texture_filter_anisotropic") === !0) {
      const $ = e.get("EXT_texture_filter_anisotropic");
      if (_.magFilter === gt || _.minFilter !== pr && _.minFilter !== _i || _.type === an && e.has("OES_texture_float_linear") === !1 || a === !1 && _.type === gi && e.has("OES_texture_half_float_linear") === !1) return;
      (_.anisotropy > 1 || n.get(_).__currentAnisotropy) && (i.texParameterf(M, $.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(_.anisotropy, r.getMaxAnisotropy())), n.get(_).__currentAnisotropy = _.anisotropy);
    }
  }
  function j(M, _) {
    let I = !1;
    M.__webglInit === void 0 && (M.__webglInit = !0, _.addEventListener("dispose", A));
    const $ = _.source;
    let K = p.get($);
    K === void 0 && (K = {}, p.set($, K));
    const J = F(_);
    if (J !== M.__cacheKey) {
      K[J] === void 0 && (K[J] = {
        texture: i.createTexture(),
        usedTimes: 0
      }, o.memory.textures++, I = !0), K[J].usedTimes++;
      const me = K[M.__cacheKey];
      me !== void 0 && (K[M.__cacheKey].usedTimes--, me.usedTimes === 0 && y(_)), M.__cacheKey = J, M.__webglTexture = K[J].texture;
    }
    return I;
  }
  function oe(M, _, I) {
    let $ = i.TEXTURE_2D;
    (_.isDataArrayTexture || _.isCompressedArrayTexture) && ($ = i.TEXTURE_2D_ARRAY), _.isData3DTexture && ($ = i.TEXTURE_3D);
    const K = j(M, _), J = _.source;
    t.bindTexture($, M.__webglTexture, i.TEXTURE0 + I);
    const me = n.get(J);
    if (J.version !== me.__version || K === !0) {
      t.activeTexture(i.TEXTURE0 + I);
      const ae = Ke.getPrimaries(Ke.workingColorSpace), he = _.colorSpace === Ct ? null : Ke.getPrimaries(_.colorSpace), ye = _.colorSpace === Ct || ae === he ? i.NONE : i.BROWSER_DEFAULT_WEBGL;
      i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, _.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, _.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, _.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, ye);
      const Fe = u(_) && f(_.image) === !1;
      let ee = v(_.image, Fe, !1, r.maxTextureSize);
      ee = be(_, ee);
      const Ye = f(ee) || a, ze = s.convert(_.format, _.colorSpace);
      let De = s.convert(_.type), Ee = R(_.internalFormat, ze, De, _.colorSpace, _.isVideoTexture);
      H($, _, Ye);
      let ue;
      const T = _.mipmaps, ne = a && _.isVideoTexture !== !0 && Ee !== _o, xe = me.__version === void 0 || K === !0, fe = D(_, ee, Ye);
      if (_.isDepthTexture)
        Ee = i.DEPTH_COMPONENT, a ? _.type === an ? Ee = i.DEPTH_COMPONENT32F : _.type === sn ? Ee = i.DEPTH_COMPONENT24 : _.type === En ? Ee = i.DEPTH24_STENCIL8 : Ee = i.DEPTH_COMPONENT16 : _.type === an && console.error("WebGLRenderer: Floating point depth texture requires WebGL2."), _.format === yn && Ee === i.DEPTH_COMPONENT && _.type !== as && _.type !== sn && (console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."), _.type = sn, De = s.convert(_.type)), _.format === ti && Ee === i.DEPTH_COMPONENT && (Ee = i.DEPTH_STENCIL, _.type !== En && (console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."), _.type = En, De = s.convert(_.type))), xe && (ne ? t.texStorage2D(i.TEXTURE_2D, 1, Ee, ee.width, ee.height) : t.texImage2D(i.TEXTURE_2D, 0, Ee, ee.width, ee.height, 0, ze, De, null));
      else if (_.isDataTexture)
        if (T.length > 0 && Ye) {
          ne && xe && t.texStorage2D(i.TEXTURE_2D, fe, Ee, T[0].width, T[0].height);
          for (let te = 0, w = T.length; te < w; te++)
            ue = T[te], ne ? t.texSubImage2D(i.TEXTURE_2D, te, 0, 0, ue.width, ue.height, ze, De, ue.data) : t.texImage2D(i.TEXTURE_2D, te, Ee, ue.width, ue.height, 0, ze, De, ue.data);
          _.generateMipmaps = !1;
        } else
          ne ? (xe && t.texStorage2D(i.TEXTURE_2D, fe, Ee, ee.width, ee.height), t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, ee.width, ee.height, ze, De, ee.data)) : t.texImage2D(i.TEXTURE_2D, 0, Ee, ee.width, ee.height, 0, ze, De, ee.data);
      else if (_.isCompressedTexture)
        if (_.isCompressedArrayTexture) {
          ne && xe && t.texStorage3D(i.TEXTURE_2D_ARRAY, fe, Ee, T[0].width, T[0].height, ee.depth);
          for (let te = 0, w = T.length; te < w; te++)
            ue = T[te], _.format !== Ft ? ze !== null ? ne ? t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY, te, 0, 0, 0, ue.width, ue.height, ee.depth, ze, ue.data, 0, 0) : t.compressedTexImage3D(i.TEXTURE_2D_ARRAY, te, Ee, ue.width, ue.height, ee.depth, 0, ue.data, 0, 0) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : ne ? t.texSubImage3D(i.TEXTURE_2D_ARRAY, te, 0, 0, 0, ue.width, ue.height, ee.depth, ze, De, ue.data) : t.texImage3D(i.TEXTURE_2D_ARRAY, te, Ee, ue.width, ue.height, ee.depth, 0, ze, De, ue.data);
        } else {
          ne && xe && t.texStorage2D(i.TEXTURE_2D, fe, Ee, T[0].width, T[0].height);
          for (let te = 0, w = T.length; te < w; te++)
            ue = T[te], _.format !== Ft ? ze !== null ? ne ? t.compressedTexSubImage2D(i.TEXTURE_2D, te, 0, 0, ue.width, ue.height, ze, ue.data) : t.compressedTexImage2D(i.TEXTURE_2D, te, Ee, ue.width, ue.height, 0, ue.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : ne ? t.texSubImage2D(i.TEXTURE_2D, te, 0, 0, ue.width, ue.height, ze, De, ue.data) : t.texImage2D(i.TEXTURE_2D, te, Ee, ue.width, ue.height, 0, ze, De, ue.data);
        }
      else if (_.isDataArrayTexture)
        ne ? (xe && t.texStorage3D(i.TEXTURE_2D_ARRAY, fe, Ee, ee.width, ee.height, ee.depth), t.texSubImage3D(i.TEXTURE_2D_ARRAY, 0, 0, 0, 0, ee.width, ee.height, ee.depth, ze, De, ee.data)) : t.texImage3D(i.TEXTURE_2D_ARRAY, 0, Ee, ee.width, ee.height, ee.depth, 0, ze, De, ee.data);
      else if (_.isData3DTexture)
        ne ? (xe && t.texStorage3D(i.TEXTURE_3D, fe, Ee, ee.width, ee.height, ee.depth), t.texSubImage3D(i.TEXTURE_3D, 0, 0, 0, 0, ee.width, ee.height, ee.depth, ze, De, ee.data)) : t.texImage3D(i.TEXTURE_3D, 0, Ee, ee.width, ee.height, ee.depth, 0, ze, De, ee.data);
      else if (_.isFramebufferTexture) {
        if (xe)
          if (ne)
            t.texStorage2D(i.TEXTURE_2D, fe, Ee, ee.width, ee.height);
          else {
            let te = ee.width, w = ee.height;
            for (let ie = 0; ie < fe; ie++)
              t.texImage2D(i.TEXTURE_2D, ie, Ee, te, w, 0, ze, De, null), te >>= 1, w >>= 1;
          }
      } else if (T.length > 0 && Ye) {
        ne && xe && t.texStorage2D(i.TEXTURE_2D, fe, Ee, T[0].width, T[0].height);
        for (let te = 0, w = T.length; te < w; te++)
          ue = T[te], ne ? t.texSubImage2D(i.TEXTURE_2D, te, 0, 0, ze, De, ue) : t.texImage2D(i.TEXTURE_2D, te, Ee, ze, De, ue);
        _.generateMipmaps = !1;
      } else
        ne ? (xe && t.texStorage2D(i.TEXTURE_2D, fe, Ee, ee.width, ee.height), t.texSubImage2D(i.TEXTURE_2D, 0, 0, 0, ze, De, ee)) : t.texImage2D(i.TEXTURE_2D, 0, Ee, ze, De, ee);
      b(_, Ye) && S($), me.__version = J.version, _.onUpdate && _.onUpdate(_);
    }
    M.__version = _.version;
  }
  function ve(M, _, I) {
    if (_.image.length !== 6) return;
    const $ = j(M, _), K = _.source;
    t.bindTexture(i.TEXTURE_CUBE_MAP, M.__webglTexture, i.TEXTURE0 + I);
    const J = n.get(K);
    if (K.version !== J.__version || $ === !0) {
      t.activeTexture(i.TEXTURE0 + I);
      const me = Ke.getPrimaries(Ke.workingColorSpace), ae = _.colorSpace === Ct ? null : Ke.getPrimaries(_.colorSpace), he = _.colorSpace === Ct || me === ae ? i.NONE : i.BROWSER_DEFAULT_WEBGL;
      i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, _.flipY), i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL, _.premultiplyAlpha), i.pixelStorei(i.UNPACK_ALIGNMENT, _.unpackAlignment), i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL, he);
      const ye = _.isCompressedTexture || _.image[0].isCompressedTexture, Fe = _.image[0] && _.image[0].isDataTexture, ee = [];
      for (let te = 0; te < 6; te++)
        !ye && !Fe ? ee[te] = v(_.image[te], !1, !0, r.maxCubemapSize) : ee[te] = Fe ? _.image[te].image : _.image[te], ee[te] = be(_, ee[te]);
      const Ye = ee[0], ze = f(Ye) || a, De = s.convert(_.format, _.colorSpace), Ee = s.convert(_.type), ue = R(_.internalFormat, De, Ee, _.colorSpace), T = a && _.isVideoTexture !== !0, ne = J.__version === void 0 || $ === !0;
      let xe = D(_, Ye, ze);
      H(i.TEXTURE_CUBE_MAP, _, ze);
      let fe;
      if (ye) {
        T && ne && t.texStorage2D(i.TEXTURE_CUBE_MAP, xe, ue, Ye.width, Ye.height);
        for (let te = 0; te < 6; te++) {
          fe = ee[te].mipmaps;
          for (let w = 0; w < fe.length; w++) {
            const ie = fe[w];
            _.format !== Ft ? De !== null ? T ? t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w, 0, 0, ie.width, ie.height, De, ie.data) : t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w, ue, ie.width, ie.height, 0, ie.data) : console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : T ? t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w, 0, 0, ie.width, ie.height, De, Ee, ie.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w, ue, ie.width, ie.height, 0, De, Ee, ie.data);
          }
        }
      } else {
        fe = _.mipmaps, T && ne && (fe.length > 0 && xe++, t.texStorage2D(i.TEXTURE_CUBE_MAP, xe, ue, ee[0].width, ee[0].height));
        for (let te = 0; te < 6; te++)
          if (Fe) {
            T ? t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, 0, 0, 0, ee[te].width, ee[te].height, De, Ee, ee[te].data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, 0, ue, ee[te].width, ee[te].height, 0, De, Ee, ee[te].data);
            for (let w = 0; w < fe.length; w++) {
              const le = fe[w].image[te].image;
              T ? t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w + 1, 0, 0, le.width, le.height, De, Ee, le.data) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w + 1, ue, le.width, le.height, 0, De, Ee, le.data);
            }
          } else {
            T ? t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, 0, 0, 0, De, Ee, ee[te]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, 0, ue, De, Ee, ee[te]);
            for (let w = 0; w < fe.length; w++) {
              const ie = fe[w];
              T ? t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w + 1, 0, 0, De, Ee, ie.image[te]) : t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X + te, w + 1, ue, De, Ee, ie.image[te]);
            }
          }
      }
      b(_, ze) && S(i.TEXTURE_CUBE_MAP), J.__version = K.version, _.onUpdate && _.onUpdate(_);
    }
    M.__version = _.version;
  }
  function _e(M, _, I, $, K, J) {
    const me = s.convert(I.format, I.colorSpace), ae = s.convert(I.type), he = R(I.internalFormat, me, ae, I.colorSpace);
    if (!n.get(_).__hasExternalTextures) {
      const Fe = Math.max(1, _.width >> J), ee = Math.max(1, _.height >> J);
      K === i.TEXTURE_3D || K === i.TEXTURE_2D_ARRAY ? t.texImage3D(K, J, he, Fe, ee, _.depth, 0, me, ae, null) : t.texImage2D(K, J, he, Fe, ee, 0, me, ae, null);
    }
    t.bindFramebuffer(i.FRAMEBUFFER, M), pe(_) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, $, K, n.get(I).__webglTexture, 0, Re(_)) : (K === i.TEXTURE_2D || K >= i.TEXTURE_CUBE_MAP_POSITIVE_X && K <= i.TEXTURE_CUBE_MAP_NEGATIVE_Z) && i.framebufferTexture2D(i.FRAMEBUFFER, $, K, n.get(I).__webglTexture, J), t.bindFramebuffer(i.FRAMEBUFFER, null);
  }
  function we(M, _, I) {
    if (i.bindRenderbuffer(i.RENDERBUFFER, M), _.depthBuffer && !_.stencilBuffer) {
      let $ = a === !0 ? i.DEPTH_COMPONENT24 : i.DEPTH_COMPONENT16;
      if (I || pe(_)) {
        const K = _.depthTexture;
        K && K.isDepthTexture && (K.type === an ? $ = i.DEPTH_COMPONENT32F : K.type === sn && ($ = i.DEPTH_COMPONENT24));
        const J = Re(_);
        pe(_) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, J, $, _.width, _.height) : i.renderbufferStorageMultisample(i.RENDERBUFFER, J, $, _.width, _.height);
      } else
        i.renderbufferStorage(i.RENDERBUFFER, $, _.width, _.height);
      i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.RENDERBUFFER, M);
    } else if (_.depthBuffer && _.stencilBuffer) {
      const $ = Re(_);
      I && pe(_) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, $, i.DEPTH24_STENCIL8, _.width, _.height) : pe(_) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, $, i.DEPTH24_STENCIL8, _.width, _.height) : i.renderbufferStorage(i.RENDERBUFFER, i.DEPTH_STENCIL, _.width, _.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.RENDERBUFFER, M);
    } else {
      const $ = _.isWebGLMultipleRenderTargets === !0 ? _.texture : [_.texture];
      for (let K = 0; K < $.length; K++) {
        const J = $[K], me = s.convert(J.format, J.colorSpace), ae = s.convert(J.type), he = R(J.internalFormat, me, ae, J.colorSpace), ye = Re(_);
        I && pe(_) === !1 ? i.renderbufferStorageMultisample(i.RENDERBUFFER, ye, he, _.width, _.height) : pe(_) ? l.renderbufferStorageMultisampleEXT(i.RENDERBUFFER, ye, he, _.width, _.height) : i.renderbufferStorage(i.RENDERBUFFER, he, _.width, _.height);
      }
    }
    i.bindRenderbuffer(i.RENDERBUFFER, null);
  }
  function Ae(M, _) {
    if (_ && _.isWebGLCubeRenderTarget) throw new Error("Depth Texture with cube render targets is not supported");
    if (t.bindFramebuffer(i.FRAMEBUFFER, M), !(_.depthTexture && _.depthTexture.isDepthTexture))
      throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");
    (!n.get(_.depthTexture).__webglTexture || _.depthTexture.image.width !== _.width || _.depthTexture.image.height !== _.height) && (_.depthTexture.image.width = _.width, _.depthTexture.image.height = _.height, _.depthTexture.needsUpdate = !0), V(_.depthTexture, 0);
    const $ = n.get(_.depthTexture).__webglTexture, K = Re(_);
    if (_.depthTexture.format === yn)
      pe(_) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, $, 0, K) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_ATTACHMENT, i.TEXTURE_2D, $, 0);
    else if (_.depthTexture.format === ti)
      pe(_) ? l.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, $, 0, K) : i.framebufferTexture2D(i.FRAMEBUFFER, i.DEPTH_STENCIL_ATTACHMENT, i.TEXTURE_2D, $, 0);
    else
      throw new Error("Unknown depthTexture format");
  }
  function ge(M) {
    const _ = n.get(M), I = M.isWebGLCubeRenderTarget === !0;
    if (M.depthTexture && !_.__autoAllocateDepthBuffer) {
      if (I) throw new Error("target.depthTexture not supported in Cube render targets");
      Ae(_.__webglFramebuffer, M);
    } else if (I) {
      _.__webglDepthbuffer = [];
      for (let $ = 0; $ < 6; $++)
        t.bindFramebuffer(i.FRAMEBUFFER, _.__webglFramebuffer[$]), _.__webglDepthbuffer[$] = i.createRenderbuffer(), we(_.__webglDepthbuffer[$], M, !1);
    } else
      t.bindFramebuffer(i.FRAMEBUFFER, _.__webglFramebuffer), _.__webglDepthbuffer = i.createRenderbuffer(), we(_.__webglDepthbuffer, M, !1);
    t.bindFramebuffer(i.FRAMEBUFFER, null);
  }
  function Pe(M, _, I) {
    const $ = n.get(M);
    _ !== void 0 && _e($.__webglFramebuffer, M, M.texture, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, 0), I !== void 0 && ge(M);
  }
  function N(M) {
    const _ = M.texture, I = n.get(M), $ = n.get(_);
    M.addEventListener("dispose", W), M.isWebGLMultipleRenderTargets !== !0 && ($.__webglTexture === void 0 && ($.__webglTexture = i.createTexture()), $.__version = _.version, o.memory.textures++);
    const K = M.isWebGLCubeRenderTarget === !0, J = M.isWebGLMultipleRenderTargets === !0, me = f(M) || a;
    if (K) {
      I.__webglFramebuffer = [];
      for (let ae = 0; ae < 6; ae++)
        if (a && _.mipmaps && _.mipmaps.length > 0) {
          I.__webglFramebuffer[ae] = [];
          for (let he = 0; he < _.mipmaps.length; he++)
            I.__webglFramebuffer[ae][he] = i.createFramebuffer();
        } else
          I.__webglFramebuffer[ae] = i.createFramebuffer();
    } else {
      if (a && _.mipmaps && _.mipmaps.length > 0) {
        I.__webglFramebuffer = [];
        for (let ae = 0; ae < _.mipmaps.length; ae++)
          I.__webglFramebuffer[ae] = i.createFramebuffer();
      } else
        I.__webglFramebuffer = i.createFramebuffer();
      if (J)
        if (r.drawBuffers) {
          const ae = M.texture;
          for (let he = 0, ye = ae.length; he < ye; he++) {
            const Fe = n.get(ae[he]);
            Fe.__webglTexture === void 0 && (Fe.__webglTexture = i.createTexture(), o.memory.textures++);
          }
        } else
          console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");
      if (a && M.samples > 0 && pe(M) === !1) {
        const ae = J ? _ : [_];
        I.__webglMultisampledFramebuffer = i.createFramebuffer(), I.__webglColorRenderbuffer = [], t.bindFramebuffer(i.FRAMEBUFFER, I.__webglMultisampledFramebuffer);
        for (let he = 0; he < ae.length; he++) {
          const ye = ae[he];
          I.__webglColorRenderbuffer[he] = i.createRenderbuffer(), i.bindRenderbuffer(i.RENDERBUFFER, I.__webglColorRenderbuffer[he]);
          const Fe = s.convert(ye.format, ye.colorSpace), ee = s.convert(ye.type), Ye = R(ye.internalFormat, Fe, ee, ye.colorSpace, M.isXRRenderTarget === !0), ze = Re(M);
          i.renderbufferStorageMultisample(i.RENDERBUFFER, ze, Ye, M.width, M.height), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + he, i.RENDERBUFFER, I.__webglColorRenderbuffer[he]);
        }
        i.bindRenderbuffer(i.RENDERBUFFER, null), M.depthBuffer && (I.__webglDepthRenderbuffer = i.createRenderbuffer(), we(I.__webglDepthRenderbuffer, M, !0)), t.bindFramebuffer(i.FRAMEBUFFER, null);
      }
    }
    if (K) {
      t.bindTexture(i.TEXTURE_CUBE_MAP, $.__webglTexture), H(i.TEXTURE_CUBE_MAP, _, me);
      for (let ae = 0; ae < 6; ae++)
        if (a && _.mipmaps && _.mipmaps.length > 0)
          for (let he = 0; he < _.mipmaps.length; he++)
            _e(I.__webglFramebuffer[ae][he], M, _, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + ae, he);
        else
          _e(I.__webglFramebuffer[ae], M, _, i.COLOR_ATTACHMENT0, i.TEXTURE_CUBE_MAP_POSITIVE_X + ae, 0);
      b(_, me) && S(i.TEXTURE_CUBE_MAP), t.unbindTexture();
    } else if (J) {
      const ae = M.texture;
      for (let he = 0, ye = ae.length; he < ye; he++) {
        const Fe = ae[he], ee = n.get(Fe);
        t.bindTexture(i.TEXTURE_2D, ee.__webglTexture), H(i.TEXTURE_2D, Fe, me), _e(I.__webglFramebuffer, M, Fe, i.COLOR_ATTACHMENT0 + he, i.TEXTURE_2D, 0), b(Fe, me) && S(i.TEXTURE_2D);
      }
      t.unbindTexture();
    } else {
      let ae = i.TEXTURE_2D;
      if ((M.isWebGL3DRenderTarget || M.isWebGLArrayRenderTarget) && (a ? ae = M.isWebGL3DRenderTarget ? i.TEXTURE_3D : i.TEXTURE_2D_ARRAY : console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")), t.bindTexture(ae, $.__webglTexture), H(ae, _, me), a && _.mipmaps && _.mipmaps.length > 0)
        for (let he = 0; he < _.mipmaps.length; he++)
          _e(I.__webglFramebuffer[he], M, _, i.COLOR_ATTACHMENT0, ae, he);
      else
        _e(I.__webglFramebuffer, M, _, i.COLOR_ATTACHMENT0, ae, 0);
      b(_, me) && S(ae), t.unbindTexture();
    }
    M.depthBuffer && ge(M);
  }
  function rt(M) {
    const _ = f(M) || a, I = M.isWebGLMultipleRenderTargets === !0 ? M.texture : [M.texture];
    for (let $ = 0, K = I.length; $ < K; $++) {
      const J = I[$];
      if (b(J, _)) {
        const me = M.isWebGLCubeRenderTarget ? i.TEXTURE_CUBE_MAP : i.TEXTURE_2D, ae = n.get(J).__webglTexture;
        t.bindTexture(me, ae), S(me), t.unbindTexture();
      }
    }
  }
  function Me(M) {
    if (a && M.samples > 0 && pe(M) === !1) {
      const _ = M.isWebGLMultipleRenderTargets ? M.texture : [M.texture], I = M.width, $ = M.height;
      let K = i.COLOR_BUFFER_BIT;
      const J = [], me = M.stencilBuffer ? i.DEPTH_STENCIL_ATTACHMENT : i.DEPTH_ATTACHMENT, ae = n.get(M), he = M.isWebGLMultipleRenderTargets === !0;
      if (he)
        for (let ye = 0; ye < _.length; ye++)
          t.bindFramebuffer(i.FRAMEBUFFER, ae.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ye, i.RENDERBUFFER, null), t.bindFramebuffer(i.FRAMEBUFFER, ae.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ye, i.TEXTURE_2D, null, 0);
      t.bindFramebuffer(i.READ_FRAMEBUFFER, ae.__webglMultisampledFramebuffer), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, ae.__webglFramebuffer);
      for (let ye = 0; ye < _.length; ye++) {
        J.push(i.COLOR_ATTACHMENT0 + ye), M.depthBuffer && J.push(me);
        const Fe = ae.__ignoreDepthValues !== void 0 ? ae.__ignoreDepthValues : !1;
        if (Fe === !1 && (M.depthBuffer && (K |= i.DEPTH_BUFFER_BIT), M.stencilBuffer && (K |= i.STENCIL_BUFFER_BIT)), he && i.framebufferRenderbuffer(i.READ_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.RENDERBUFFER, ae.__webglColorRenderbuffer[ye]), Fe === !0 && (i.invalidateFramebuffer(i.READ_FRAMEBUFFER, [me]), i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER, [me])), he) {
          const ee = n.get(_[ye]).__webglTexture;
          i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0, i.TEXTURE_2D, ee, 0);
        }
        i.blitFramebuffer(0, 0, I, $, 0, 0, I, $, K, i.NEAREST), c && i.invalidateFramebuffer(i.READ_FRAMEBUFFER, J);
      }
      if (t.bindFramebuffer(i.READ_FRAMEBUFFER, null), t.bindFramebuffer(i.DRAW_FRAMEBUFFER, null), he)
        for (let ye = 0; ye < _.length; ye++) {
          t.bindFramebuffer(i.FRAMEBUFFER, ae.__webglMultisampledFramebuffer), i.framebufferRenderbuffer(i.FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ye, i.RENDERBUFFER, ae.__webglColorRenderbuffer[ye]);
          const Fe = n.get(_[ye]).__webglTexture;
          t.bindFramebuffer(i.FRAMEBUFFER, ae.__webglFramebuffer), i.framebufferTexture2D(i.DRAW_FRAMEBUFFER, i.COLOR_ATTACHMENT0 + ye, i.TEXTURE_2D, Fe, 0);
        }
      t.bindFramebuffer(i.DRAW_FRAMEBUFFER, ae.__webglMultisampledFramebuffer);
    }
  }
  function Re(M) {
    return Math.min(r.maxSamples, M.samples);
  }
  function pe(M) {
    const _ = n.get(M);
    return a && M.samples > 0 && e.has("WEBGL_multisampled_render_to_texture") === !0 && _.__useRenderToTexture !== !1;
  }
  function je(M) {
    const _ = o.render.frame;
    h.get(M) !== _ && (h.set(M, _), M.update());
  }
  function be(M, _) {
    const I = M.colorSpace, $ = M.format, K = M.type;
    return M.isCompressedTexture === !0 || M.isVideoTexture === !0 || M.format === ts || I !== $t && I !== Ct && (Ke.getTransfer(I) === Ze ? a === !1 ? e.has("EXT_sRGB") === !0 && $ === Ft ? (M.format = ts, M.minFilter = Rt, M.generateMipmaps = !1) : _ = So.sRGBToLinear(_) : ($ !== Ft || K !== cn) && console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : console.error("THREE.WebGLTextures: Unsupported texture color space:", I)), _;
  }
  this.allocateTextureUnit = L, this.resetTextureUnits = re, this.setTexture2D = V, this.setTexture2DArray = Y, this.setTexture3D = X, this.setTextureCube = k, this.rebindTextures = Pe, this.setupRenderTarget = N, this.updateRenderTargetMipmap = rt, this.updateMultisampleRenderTarget = Me, this.setupDepthRenderbuffer = ge, this.setupFrameBufferTexture = _e, this.useMultisampledRTT = pe;
}
function Yf(i, e, t) {
  const n = t.isWebGL2;
  function r(s, o = Ct) {
    let a;
    const l = Ke.getTransfer(o);
    if (s === cn) return i.UNSIGNED_BYTE;
    if (s === uo) return i.UNSIGNED_SHORT_4_4_4_4;
    if (s === ho) return i.UNSIGNED_SHORT_5_5_5_1;
    if (s === wl) return i.BYTE;
    if (s === Rl) return i.SHORT;
    if (s === as) return i.UNSIGNED_SHORT;
    if (s === co) return i.INT;
    if (s === sn) return i.UNSIGNED_INT;
    if (s === an) return i.FLOAT;
    if (s === gi)
      return n ? i.HALF_FLOAT : (a = e.get("OES_texture_half_float"), a !== null ? a.HALF_FLOAT_OES : null);
    if (s === Cl) return i.ALPHA;
    if (s === Ft) return i.RGBA;
    if (s === Ll) return i.LUMINANCE;
    if (s === Pl) return i.LUMINANCE_ALPHA;
    if (s === yn) return i.DEPTH_COMPONENT;
    if (s === ti) return i.DEPTH_STENCIL;
    if (s === ts)
      return a = e.get("EXT_sRGB"), a !== null ? a.SRGB_ALPHA_EXT : null;
    if (s === Dl) return i.RED;
    if (s === fo) return i.RED_INTEGER;
    if (s === Ul) return i.RG;
    if (s === po) return i.RG_INTEGER;
    if (s === mo) return i.RGBA_INTEGER;
    if (s === mr || s === _r || s === gr || s === vr)
      if (l === Ze)
        if (a = e.get("WEBGL_compressed_texture_s3tc_srgb"), a !== null) {
          if (s === mr) return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;
          if (s === _r) return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
          if (s === gr) return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
          if (s === vr) return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
        } else
          return null;
      else if (a = e.get("WEBGL_compressed_texture_s3tc"), a !== null) {
        if (s === mr) return a.COMPRESSED_RGB_S3TC_DXT1_EXT;
        if (s === _r) return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;
        if (s === gr) return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;
        if (s === vr) return a.COMPRESSED_RGBA_S3TC_DXT5_EXT;
      } else
        return null;
    if (s === Rs || s === Cs || s === Ls || s === Ps)
      if (a = e.get("WEBGL_compressed_texture_pvrtc"), a !== null) {
        if (s === Rs) return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
        if (s === Cs) return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
        if (s === Ls) return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
        if (s === Ps) return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
      } else
        return null;
    if (s === _o)
      return a = e.get("WEBGL_compressed_texture_etc1"), a !== null ? a.COMPRESSED_RGB_ETC1_WEBGL : null;
    if (s === Ds || s === Us)
      if (a = e.get("WEBGL_compressed_texture_etc"), a !== null) {
        if (s === Ds) return l === Ze ? a.COMPRESSED_SRGB8_ETC2 : a.COMPRESSED_RGB8_ETC2;
        if (s === Us) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : a.COMPRESSED_RGBA8_ETC2_EAC;
      } else
        return null;
    if (s === Is || s === Ns || s === Fs || s === Os || s === Bs || s === zs || s === Gs || s === Hs || s === Vs || s === ks || s === Ws || s === Xs || s === qs || s === Ys)
      if (a = e.get("WEBGL_compressed_texture_astc"), a !== null) {
        if (s === Is) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : a.COMPRESSED_RGBA_ASTC_4x4_KHR;
        if (s === Ns) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : a.COMPRESSED_RGBA_ASTC_5x4_KHR;
        if (s === Fs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : a.COMPRESSED_RGBA_ASTC_5x5_KHR;
        if (s === Os) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : a.COMPRESSED_RGBA_ASTC_6x5_KHR;
        if (s === Bs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : a.COMPRESSED_RGBA_ASTC_6x6_KHR;
        if (s === zs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : a.COMPRESSED_RGBA_ASTC_8x5_KHR;
        if (s === Gs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : a.COMPRESSED_RGBA_ASTC_8x6_KHR;
        if (s === Hs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : a.COMPRESSED_RGBA_ASTC_8x8_KHR;
        if (s === Vs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : a.COMPRESSED_RGBA_ASTC_10x5_KHR;
        if (s === ks) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : a.COMPRESSED_RGBA_ASTC_10x6_KHR;
        if (s === Ws) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : a.COMPRESSED_RGBA_ASTC_10x8_KHR;
        if (s === Xs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : a.COMPRESSED_RGBA_ASTC_10x10_KHR;
        if (s === qs) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : a.COMPRESSED_RGBA_ASTC_12x10_KHR;
        if (s === Ys) return l === Ze ? a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : a.COMPRESSED_RGBA_ASTC_12x12_KHR;
      } else
        return null;
    if (s === xr || s === js || s === Ks)
      if (a = e.get("EXT_texture_compression_bptc"), a !== null) {
        if (s === xr) return l === Ze ? a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : a.COMPRESSED_RGBA_BPTC_UNORM_EXT;
        if (s === js) return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
        if (s === Ks) return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
      } else
        return null;
    if (s === Il || s === Zs || s === $s || s === Js)
      if (a = e.get("EXT_texture_compression_rgtc"), a !== null) {
        if (s === xr) return a.COMPRESSED_RED_RGTC1_EXT;
        if (s === Zs) return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;
        if (s === $s) return a.COMPRESSED_RED_GREEN_RGTC2_EXT;
        if (s === Js) return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
      } else
        return null;
    return s === En ? n ? i.UNSIGNED_INT_24_8 : (a = e.get("WEBGL_depth_texture"), a !== null ? a.UNSIGNED_INT_24_8_WEBGL : null) : i[s] !== void 0 ? i[s] : null;
  }
  return { convert: r };
}
class jf extends Tt {
  constructor(e = []) {
    super(), this.isArrayCamera = !0, this.cameras = e;
  }
}
class qi extends dt {
  constructor() {
    super(), this.isGroup = !0, this.type = "Group";
  }
}
const Kf = { type: "move" };
class kr {
  constructor() {
    this._targetRay = null, this._grip = null, this._hand = null;
  }
  getHandSpace() {
    return this._hand === null && (this._hand = new qi(), 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 qi(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new P(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new P()), this._targetRay;
  }
  getGripSpace() {
    return this._grip === null && (this._grip = new qi(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new P(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new P()), 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) {
      const t = this._hand;
      if (t)
        for (const 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, s = null, o = null;
    const a = this._targetRay, l = this._grip, c = this._hand;
    if (e && t.session.visibilityState !== "visible-blurred") {
      if (c && e.hand) {
        o = !0;
        for (const v of e.hand.values()) {
          const f = t.getJointPose(v, n), u = this._getHandJoint(c, v);
          f !== null && (u.matrix.fromArray(f.transform.matrix), u.matrix.decompose(u.position, u.rotation, u.scale), u.matrixWorldNeedsUpdate = !0, u.jointRadius = f.radius), u.visible = f !== null;
        }
        const h = c.joints["index-finger-tip"], d = c.joints["thumb-tip"], p = h.position.distanceTo(d.position), m = 0.02, g = 5e-3;
        c.inputState.pinching && p > m + g ? (c.inputState.pinching = !1, this.dispatchEvent({
          type: "pinchend",
          handedness: e.handedness,
          target: this
        })) : !c.inputState.pinching && p <= m - g && (c.inputState.pinching = !0, this.dispatchEvent({
          type: "pinchstart",
          handedness: e.handedness,
          target: this
        }));
      } else
        l !== null && e.gripSpace && (s = t.getPose(e.gripSpace, n), s !== null && (l.matrix.fromArray(s.transform.matrix), l.matrix.decompose(l.position, l.rotation, l.scale), l.matrixWorldNeedsUpdate = !0, s.linearVelocity ? (l.hasLinearVelocity = !0, l.linearVelocity.copy(s.linearVelocity)) : l.hasLinearVelocity = !1, s.angularVelocity ? (l.hasAngularVelocity = !0, l.angularVelocity.copy(s.angularVelocity)) : l.hasAngularVelocity = !1));
      a !== null && (r = t.getPose(e.targetRaySpace, n), r === null && s !== null && (r = s), r !== null && (a.matrix.fromArray(r.transform.matrix), a.matrix.decompose(a.position, a.rotation, a.scale), a.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (a.hasLinearVelocity = !0, a.linearVelocity.copy(r.linearVelocity)) : a.hasLinearVelocity = !1, r.angularVelocity ? (a.hasAngularVelocity = !0, a.angularVelocity.copy(r.angularVelocity)) : a.hasAngularVelocity = !1, this.dispatchEvent(Kf)));
    }
    return a !== null && (a.visible = r !== null), l !== null && (l.visible = s !== null), c !== null && (c.visible = o !== null), this;
  }
  // private method
  _getHandJoint(e, t) {
    if (e.joints[t.jointName] === void 0) {
      const n = new qi();
      n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n);
    }
    return e.joints[t.jointName];
  }
}
class Zf extends Rn {
  constructor(e, t) {
    super();
    const n = this;
    let r = null, s = 1, o = null, a = "local-floor", l = 1, c = null, h = null, d = null, p = null, m = null, g = null;
    const v = t.getContextAttributes();
    let f = null, u = null;
    const b = [], S = [], R = new Ie();
    let D = null;
    const C = new Tt();
    C.layers.enable(1), C.viewport = new $e();
    const A = new Tt();
    A.layers.enable(2), A.viewport = new $e();
    const W = [C, A], x = new jf();
    x.layers.enable(1), x.layers.enable(2);
    let y = null, z = null;
    this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(H) {
      let j = b[H];
      return j === void 0 && (j = new kr(), b[H] = j), j.getTargetRaySpace();
    }, this.getControllerGrip = function(H) {
      let j = b[H];
      return j === void 0 && (j = new kr(), b[H] = j), j.getGripSpace();
    }, this.getHand = function(H) {
      let j = b[H];
      return j === void 0 && (j = new kr(), b[H] = j), j.getHandSpace();
    };
    function Z(H) {
      const j = S.indexOf(H.inputSource);
      if (j === -1)
        return;
      const oe = b[j];
      oe !== void 0 && (oe.update(H.inputSource, H.frame, c || o), oe.dispatchEvent({ type: H.type, data: H.inputSource }));
    }
    function re() {
      r.removeEventListener("select", Z), r.removeEventListener("selectstart", Z), r.removeEventListener("selectend", Z), r.removeEventListener("squeeze", Z), r.removeEventListener("squeezestart", Z), r.removeEventListener("squeezeend", Z), r.removeEventListener("end", re), r.removeEventListener("inputsourceschange", L);
      for (let H = 0; H < b.length; H++) {
        const j = S[H];
        j !== null && (S[H] = null, b[H].disconnect(j));
      }
      y = null, z = null, e.setRenderTarget(f), m = null, p = null, d = null, r = null, u = null, ce.stop(), n.isPresenting = !1, e.setPixelRatio(D), e.setSize(R.width, R.height, !1), n.dispatchEvent({ type: "sessionend" });
    }
    this.setFramebufferScaleFactor = function(H) {
      s = H, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.");
    }, this.setReferenceSpaceType = function(H) {
      a = H, n.isPresenting === !0 && console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.");
    }, this.getReferenceSpace = function() {
      return c || o;
    }, this.setReferenceSpace = function(H) {
      c = H;
    }, this.getBaseLayer = function() {
      return p !== null ? p : m;
    }, this.getBinding = function() {
      return d;
    }, this.getFrame = function() {
      return g;
    }, this.getSession = function() {
      return r;
    }, this.setSession = async function(H) {
      if (r = H, r !== null) {
        if (f = e.getRenderTarget(), r.addEventListener("select", Z), r.addEventListener("selectstart", Z), r.addEventListener("selectend", Z), r.addEventListener("squeeze", Z), r.addEventListener("squeezestart", Z), r.addEventListener("squeezeend", Z), r.addEventListener("end", re), r.addEventListener("inputsourceschange", L), v.xrCompatible !== !0 && await t.makeXRCompatible(), D = e.getPixelRatio(), e.getSize(R), r.renderState.layers === void 0 || e.capabilities.isWebGL2 === !1) {
          const j = {
            antialias: r.renderState.layers === void 0 ? v.antialias : !0,
            alpha: !0,
            depth: v.depth,
            stencil: v.stencil,
            framebufferScaleFactor: s
          };
          m = new XRWebGLLayer(r, t, j), r.updateRenderState({ baseLayer: m }), e.setPixelRatio(1), e.setSize(m.framebufferWidth, m.framebufferHeight, !1), u = new bn(
            m.framebufferWidth,
            m.framebufferHeight,
            {
              format: Ft,
              type: cn,
              colorSpace: e.outputColorSpace,
              stencilBuffer: v.stencil
            }
          );
        } else {
          let j = null, oe = null, ve = null;
          v.depth && (ve = v.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, j = v.stencil ? ti : yn, oe = v.stencil ? En : sn);
          const _e = {
            colorFormat: t.RGBA8,
            depthFormat: ve,
            scaleFactor: s
          };
          d = new XRWebGLBinding(r, t), p = d.createProjectionLayer(_e), r.updateRenderState({ layers: [p] }), e.setPixelRatio(1), e.setSize(p.textureWidth, p.textureHeight, !1), u = new bn(
            p.textureWidth,
            p.textureHeight,
            {
              format: Ft,
              type: cn,
              depthTexture: new Io(p.textureWidth, p.textureHeight, oe, void 0, void 0, void 0, void 0, void 0, void 0, j),
              stencilBuffer: v.stencil,
              colorSpace: e.outputColorSpace,
              samples: v.antialias ? 4 : 0
            }
          );
          const we = e.properties.get(u);
          we.__ignoreDepthValues = p.ignoreDepthValues;
        }
        u.isXRRenderTarget = !0, this.setFoveation(l), c = null, o = await r.requestReferenceSpace(a), ce.setContext(r), ce.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" });
      }
    }, this.getEnvironmentBlendMode = function() {
      if (r !== null)
        return r.environmentBlendMode;
    };
    function L(H) {
      for (let j = 0; j < H.removed.length; j++) {
        const oe = H.removed[j], ve = S.indexOf(oe);
        ve >= 0 && (S[ve] = null, b[ve].disconnect(oe));
      }
      for (let j = 0; j < H.added.length; j++) {
        const oe = H.added[j];
        let ve = S.indexOf(oe);
        if (ve === -1) {
          for (let we = 0; we < b.length; we++)
            if (we >= S.length) {
              S.push(oe), ve = we;
              break;
            } else if (S[we] === null) {
              S[we] = oe, ve = we;
              break;
            }
          if (ve === -1) break;
        }
        const _e = b[ve];
        _e && _e.connect(oe);
      }
    }
    const F = new P(), V = new P();
    function Y(H, j, oe) {
      F.setFromMatrixPosition(j.matrixWorld), V.setFromMatrixPosition(oe.matrixWorld);
      const ve = F.distanceTo(V), _e = j.projectionMatrix.elements, we = oe.projectionMatrix.elements, Ae = _e[14] / (_e[10] - 1), ge = _e[14] / (_e[10] + 1), Pe = (_e[9] + 1) / _e[5], N = (_e[9] - 1) / _e[5], rt = (_e[8] - 1) / _e[0], Me = (we[8] + 1) / we[0], Re = Ae * rt, pe = Ae * Me, je = ve / (-rt + Me), be = je * -rt;
      j.matrixWorld.decompose(H.position, H.quaternion, H.scale), H.translateX(be), H.translateZ(je), H.matrixWorld.compose(H.position, H.quaternion, H.scale), H.matrixWorldInverse.copy(H.matrixWorld).invert();
      const M = Ae + je, _ = ge + je, I = Re - be, $ = pe + (ve - be), K = Pe * ge / _ * M, J = N * ge / _ * M;
      H.projectionMatrix.makePerspective(I, $, K, J, M, _), H.projectionMatrixInverse.copy(H.projectionMatrix).invert();
    }
    function X(H, j) {
      j === null ? H.matrixWorld.copy(H.matrix) : H.matrixWorld.multiplyMatrices(j.matrixWorld, H.matrix), H.matrixWorldInverse.copy(H.matrixWorld).invert();
    }
    this.updateCamera = function(H) {
      if (r === null) return;
      x.near = A.near = C.near = H.near, x.far = A.far = C.far = H.far, (y !== x.near || z !== x.far) && (r.updateRenderState({
        depthNear: x.near,
        depthFar: x.far
      }), y = x.near, z = x.far);
      const j = H.parent, oe = x.cameras;
      X(x, j);
      for (let ve = 0; ve < oe.length; ve++)
        X(oe[ve], j);
      oe.length === 2 ? Y(x, C, A) : x.projectionMatrix.copy(C.projectionMatrix), k(H, x, j);
    };
    function k(H, j, oe) {
      oe === null ? H.matrix.copy(j.matrixWorld) : (H.matrix.copy(oe.matrixWorld), H.matrix.invert(), H.matrix.multiply(j.matrixWorld)), H.matrix.decompose(H.position, H.quaternion, H.scale), H.updateMatrixWorld(!0), H.projectionMatrix.copy(j.projectionMatrix), H.projectionMatrixInverse.copy(j.projectionMatrixInverse), H.isPerspectiveCamera && (H.fov = ns * 2 * Math.atan(1 / H.projectionMatrix.elements[5]), H.zoom = 1);
    }
    this.getCamera = function() {
      return x;
    }, this.getFoveation = function() {
      if (!(p === null && m === null))
        return l;
    }, this.setFoveation = function(H) {
      l = H, p !== null && (p.fixedFoveation = H), m !== null && m.fixedFoveation !== void 0 && (m.fixedFoveation = H);
    };
    let q = null;
    function Q(H, j) {
      if (h = j.getViewerPose(c || o), g = j, h !== null) {
        const oe = h.views;
        m !== null && (e.setRenderTargetFramebuffer(u, m.framebuffer), e.setRenderTarget(u));
        let ve = !1;
        oe.length !== x.cameras.length && (x.cameras.length = 0, ve = !0);
        for (let _e = 0; _e < oe.length; _e++) {
          const we = oe[_e];
          let Ae = null;
          if (m !== null)
            Ae = m.getViewport(we);
          else {
            const Pe = d.getViewSubImage(p, we);
            Ae = Pe.viewport, _e === 0 && (e.setRenderTargetTextures(
              u,
              Pe.colorTexture,
              p.ignoreDepthValues ? void 0 : Pe.depthStencilTexture
            ), e.setRenderTarget(u));
          }
          let ge = W[_e];
          ge === void 0 && (ge = new Tt(), ge.layers.enable(_e), ge.viewport = new $e(), W[_e] = ge), ge.matrix.fromArray(we.transform.matrix), ge.matrix.decompose(ge.position, ge.quaternion, ge.scale), ge.projectionMatrix.fromArray(we.projectionMatrix), ge.projectionMatrixInverse.copy(ge.projectionMatrix).invert(), ge.viewport.set(Ae.x, Ae.y, Ae.width, Ae.height), _e === 0 && (x.matrix.copy(ge.matrix), x.matrix.decompose(x.position, x.quaternion, x.scale)), ve === !0 && x.cameras.push(ge);
        }
      }
      for (let oe = 0; oe < b.length; oe++) {
        const ve = S[oe], _e = b[oe];
        ve !== null && _e !== void 0 && _e.update(ve, j, c || o);
      }
      q && q(H, j), j.detectedPlanes && n.dispatchEvent({ type: "planesdetected", data: j }), g = null;
    }
    const ce = new Do();
    ce.setAnimationLoop(Q), this.setAnimationLoop = function(H) {
      q = H;
    }, this.dispose = function() {
    };
  }
}
function $f(i, e) {
  function t(f, u) {
    f.matrixAutoUpdate === !0 && f.updateMatrix(), u.value.copy(f.matrix);
  }
  function n(f, u) {
    u.color.getRGB(f.fogColor.value, Co(i)), u.isFog ? (f.fogNear.value = u.near, f.fogFar.value = u.far) : u.isFogExp2 && (f.fogDensity.value = u.density);
  }
  function r(f, u, b, S, R) {
    u.isMeshBasicMaterial || u.isMeshLambertMaterial ? s(f, u) : u.isMeshToonMaterial ? (s(f, u), d(f, u)) : u.isMeshPhongMaterial ? (s(f, u), h(f, u)) : u.isMeshStandardMaterial ? (s(f, u), p(f, u), u.isMeshPhysicalMaterial && m(f, u, R)) : u.isMeshMatcapMaterial ? (s(f, u), g(f, u)) : u.isMeshDepthMaterial ? s(f, u) : u.isMeshDistanceMaterial ? (s(f, u), v(f, u)) : u.isMeshNormalMaterial ? s(f, u) : u.isLineBasicMaterial ? (o(f, u), u.isLineDashedMaterial && a(f, u)) : u.isPointsMaterial ? l(f, u, b, S) : u.isSpriteMaterial ? c(f, u) : u.isShadowMaterial ? (f.color.value.copy(u.color), f.opacity.value = u.opacity) : u.isShaderMaterial && (u.uniformsNeedUpdate = !1);
  }
  function s(f, u) {
    f.opacity.value = u.opacity, u.color && f.diffuse.value.copy(u.color), u.emissive && f.emissive.value.copy(u.emissive).multiplyScalar(u.emissiveIntensity), u.map && (f.map.value = u.map, t(u.map, f.mapTransform)), u.alphaMap && (f.alphaMap.value = u.alphaMap, t(u.alphaMap, f.alphaMapTransform)), u.bumpMap && (f.bumpMap.value = u.bumpMap, t(u.bumpMap, f.bumpMapTransform), f.bumpScale.value = u.bumpScale, u.side === Mt && (f.bumpScale.value *= -1)), u.normalMap && (f.normalMap.value = u.normalMap, t(u.normalMap, f.normalMapTransform), f.normalScale.value.copy(u.normalScale), u.side === Mt && f.normalScale.value.negate()), u.displacementMap && (f.displacementMap.value = u.displacementMap, t(u.displacementMap, f.displacementMapTransform), f.displacementScale.value = u.displacementScale, f.displacementBias.value = u.displacementBias), u.emissiveMap && (f.emissiveMap.value = u.emissiveMap, t(u.emissiveMap, f.emissiveMapTransform)), u.specularMap && (f.specularMap.value = u.specularMap, t(u.specularMap, f.specularMapTransform)), u.alphaTest > 0 && (f.alphaTest.value = u.alphaTest);
    const b = e.get(u).envMap;
    if (b && (f.envMap.value = b, f.flipEnvMap.value = b.isCubeTexture && b.isRenderTargetTexture === !1 ? -1 : 1, f.reflectivity.value = u.reflectivity, f.ior.value = u.ior, f.refractionRatio.value = u.refractionRatio), u.lightMap) {
      f.lightMap.value = u.lightMap;
      const S = i._useLegacyLights === !0 ? Math.PI : 1;
      f.lightMapIntensity.value = u.lightMapIntensity * S, t(u.lightMap, f.lightMapTransform);
    }
    u.aoMap && (f.aoMap.value = u.aoMap, f.aoMapIntensity.value = u.aoMapIntensity, t(u.aoMap, f.aoMapTransform));
  }
  function o(f, u) {
    f.diffuse.value.copy(u.color), f.opacity.value = u.opacity, u.map && (f.map.value = u.map, t(u.map, f.mapTransform));
  }
  function a(f, u) {
    f.dashSize.value = u.dashSize, f.totalSize.value = u.dashSize + u.gapSize, f.scale.value = u.scale;
  }
  function l(f, u, b, S) {
    f.diffuse.value.copy(u.color), f.opacity.value = u.opacity, f.size.value = u.size * b, f.scale.value = S * 0.5, u.map && (f.map.value = u.map, t(u.map, f.uvTransform)), u.alphaMap && (f.alphaMap.value = u.alphaMap, t(u.alphaMap, f.alphaMapTransform)), u.alphaTest > 0 && (f.alphaTest.value = u.alphaTest);
  }
  function c(f, u) {
    f.diffuse.value.copy(u.color), f.opacity.value = u.opacity, f.rotation.value = u.rotation, u.map && (f.map.value = u.map, t(u.map, f.mapTransform)), u.alphaMap && (f.alphaMap.value = u.alphaMap, t(u.alphaMap, f.alphaMapTransform)), u.alphaTest > 0 && (f.alphaTest.value = u.alphaTest);
  }
  function h(f, u) {
    f.specular.value.copy(u.specular), f.shininess.value = Math.max(u.shininess, 1e-4);
  }
  function d(f, u) {
    u.gradientMap && (f.gradientMap.value = u.gradientMap);
  }
  function p(f, u) {
    f.metalness.value = u.metalness, u.metalnessMap && (f.metalnessMap.value = u.metalnessMap, t(u.metalnessMap, f.metalnessMapTransform)), f.roughness.value = u.roughness, u.roughnessMap && (f.roughnessMap.value = u.roughnessMap, t(u.roughnessMap, f.roughnessMapTransform)), e.get(u).envMap && (f.envMapIntensity.value = u.envMapIntensity);
  }
  function m(f, u, b) {
    f.ior.value = u.ior, u.sheen > 0 && (f.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen), f.sheenRoughness.value = u.sheenRoughness, u.sheenColorMap && (f.sheenColorMap.value = u.sheenColorMap, t(u.sheenColorMap, f.sheenColorMapTransform)), u.sheenRoughnessMap && (f.sheenRoughnessMap.value = u.sheenRoughnessMap, t(u.sheenRoughnessMap, f.sheenRoughnessMapTransform))), u.clearcoat > 0 && (f.clearcoat.value = u.clearcoat, f.clearcoatRoughness.value = u.clearcoatRoughness, u.clearcoatMap && (f.clearcoatMap.value = u.clearcoatMap, t(u.clearcoatMap, f.clearcoatMapTransform)), u.clearcoatRoughnessMap && (f.clearcoatRoughnessMap.value = u.clearcoatRoughnessMap, t(u.clearcoatRoughnessMap, f.clearcoatRoughnessMapTransform)), u.clearcoatNormalMap && (f.clearcoatNormalMap.value = u.clearcoatNormalMap, t(u.clearcoatNormalMap, f.clearcoatNormalMapTransform), f.clearcoatNormalScale.value.copy(u.clearcoatNormalScale), u.side === Mt && f.clearcoatNormalScale.value.negate())), u.iridescence > 0 && (f.iridescence.value = u.iridescence, f.iridescenceIOR.value = u.iridescenceIOR, f.iridescenceThicknessMinimum.value = u.iridescenceThicknessRange[0], f.iridescenceThicknessMaximum.value = u.iridescenceThicknessRange[1], u.iridescenceMap && (f.iridescenceMap.value = u.iridescenceMap, t(u.iridescenceMap, f.iridescenceMapTransform)), u.iridescenceThicknessMap && (f.iridescenceThicknessMap.value = u.iridescenceThicknessMap, t(u.iridescenceThicknessMap, f.iridescenceThicknessMapTransform))), u.transmission > 0 && (f.transmission.value = u.transmission, f.transmissionSamplerMap.value = b.texture, f.transmissionSamplerSize.value.set(b.width, b.height), u.transmissionMap && (f.transmissionMap.value = u.transmissionMap, t(u.transmissionMap, f.transmissionMapTransform)), f.thickness.value = u.thickness, u.thicknessMap && (f.thicknessMap.value = u.thicknessMap, t(u.thicknessMap, f.thicknessMapTransform)), f.attenuationDistance.value = u.attenuationDistance, f.attenuationColor.value.copy(u.attenuationColor)), u.anisotropy > 0 && (f.anisotropyVector.value.set(u.anisotropy * Math.cos(u.anisotropyRotation), u.anisotropy * Math.sin(u.anisotropyRotation)), u.anisotropyMap && (f.anisotropyMap.value = u.anisotropyMap, t(u.anisotropyMap, f.anisotropyMapTransform))), f.specularIntensity.value = u.specularIntensity, f.specularColor.value.copy(u.specularColor), u.specularColorMap && (f.specularColorMap.value = u.specularColorMap, t(u.specularColorMap, f.specularColorMapTransform)), u.specularIntensityMap && (f.specularIntensityMap.value = u.specularIntensityMap, t(u.specularIntensityMap, f.specularIntensityMapTransform));
  }
  function g(f, u) {
    u.matcap && (f.matcap.value = u.matcap);
  }
  function v(f, u) {
    const b = e.get(u).light;
    f.referencePosition.value.setFromMatrixPosition(b.matrixWorld), f.nearDistance.value = b.shadow.camera.near, f.farDistance.value = b.shadow.camera.far;
  }
  return {
    refreshFogUniforms: n,
    refreshMaterialUniforms: r
  };
}
function Jf(i, e, t, n) {
  let r = {}, s = {}, o = [];
  const a = t.isWebGL2 ? i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS) : 0;
  function l(b, S) {
    const R = S.program;
    n.uniformBlockBinding(b, R);
  }
  function c(b, S) {
    let R = r[b.id];
    R === void 0 && (g(b), R = h(b), r[b.id] = R, b.addEventListener("dispose", f));
    const D = S.program;
    n.updateUBOMapping(b, D);
    const C = e.render.frame;
    s[b.id] !== C && (p(b), s[b.id] = C);
  }
  function h(b) {
    const S = d();
    b.__bindingPointIndex = S;
    const R = i.createBuffer(), D = b.__size, C = b.usage;
    return i.bindBuffer(i.UNIFORM_BUFFER, R), i.bufferData(i.UNIFORM_BUFFER, D, C), i.bindBuffer(i.UNIFORM_BUFFER, null), i.bindBufferBase(i.UNIFORM_BUFFER, S, R), R;
  }
  function d() {
    for (let b = 0; b < a; b++)
      if (o.indexOf(b) === -1)
        return o.push(b), b;
    return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0;
  }
  function p(b) {
    const S = r[b.id], R = b.uniforms, D = b.__cache;
    i.bindBuffer(i.UNIFORM_BUFFER, S);
    for (let C = 0, A = R.length; C < A; C++) {
      const W = Array.isArray(R[C]) ? R[C] : [R[C]];
      for (let x = 0, y = W.length; x < y; x++) {
        const z = W[x];
        if (m(z, C, x, D) === !0) {
          const Z = z.__offset, re = Array.isArray(z.value) ? z.value : [z.value];
          let L = 0;
          for (let F = 0; F < re.length; F++) {
            const V = re[F], Y = v(V);
            typeof V == "number" || typeof V == "boolean" ? (z.__data[0] = V, i.bufferSubData(i.UNIFORM_BUFFER, Z + L, z.__data)) : V.isMatrix3 ? (z.__data[0] = V.elements[0], z.__data[1] = V.elements[1], z.__data[2] = V.elements[2], z.__data[3] = 0, z.__data[4] = V.elements[3], z.__data[5] = V.elements[4], z.__data[6] = V.elements[5], z.__data[7] = 0, z.__data[8] = V.elements[6], z.__data[9] = V.elements[7], z.__data[10] = V.elements[8], z.__data[11] = 0) : (V.toArray(z.__data, L), L += Y.storage / Float32Array.BYTES_PER_ELEMENT);
          }
          i.bufferSubData(i.UNIFORM_BUFFER, Z, z.__data);
        }
      }
    }
    i.bindBuffer(i.UNIFORM_BUFFER, null);
  }
  function m(b, S, R, D) {
    const C = b.value, A = S + "_" + R;
    if (D[A] === void 0)
      return typeof C == "number" || typeof C == "boolean" ? D[A] = C : D[A] = C.clone(), !0;
    {
      const W = D[A];
      if (typeof C == "number" || typeof C == "boolean") {
        if (W !== C)
          return D[A] = C, !0;
      } else if (W.equals(C) === !1)
        return W.copy(C), !0;
    }
    return !1;
  }
  function g(b) {
    const S = b.uniforms;
    let R = 0;
    const D = 16;
    for (let A = 0, W = S.length; A < W; A++) {
      const x = Array.isArray(S[A]) ? S[A] : [S[A]];
      for (let y = 0, z = x.length; y < z; y++) {
        const Z = x[y], re = Array.isArray(Z.value) ? Z.value : [Z.value];
        for (let L = 0, F = re.length; L < F; L++) {
          const V = re[L], Y = v(V), X = R % D;
          X !== 0 && D - X < Y.boundary && (R += D - X), Z.__data = new Float32Array(Y.storage / Float32Array.BYTES_PER_ELEMENT), Z.__offset = R, R += Y.storage;
        }
      }
    }
    const C = R % D;
    return C > 0 && (R += D - C), b.__size = R, b.__cache = {}, this;
  }
  function v(b) {
    const S = {
      boundary: 0,
      // bytes
      storage: 0
      // bytes
    };
    return typeof b == "number" || typeof b == "boolean" ? (S.boundary = 4, S.storage = 4) : b.isVector2 ? (S.boundary = 8, S.storage = 8) : b.isVector3 || b.isColor ? (S.boundary = 16, S.storage = 12) : b.isVector4 ? (S.boundary = 16, S.storage = 16) : b.isMatrix3 ? (S.boundary = 48, S.storage = 48) : b.isMatrix4 ? (S.boundary = 64, S.storage = 64) : b.isTexture ? console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.") : console.warn("THREE.WebGLRenderer: Unsupported uniform value type.", b), S;
  }
  function f(b) {
    const S = b.target;
    S.removeEventListener("dispose", f);
    const R = o.indexOf(S.__bindingPointIndex);
    o.splice(R, 1), i.deleteBuffer(r[S.id]), delete r[S.id], delete s[S.id];
  }
  function u() {
    for (const b in r)
      i.deleteBuffer(r[b]);
    o = [], r = {}, s = {};
  }
  return {
    bind: l,
    update: c,
    dispose: u
  };
}
class Go {
  constructor(e = {}) {
    const {
      canvas: t = Yl(),
      context: n = null,
      depth: r = !0,
      stencil: s = !0,
      alpha: o = !1,
      antialias: a = !1,
      premultipliedAlpha: l = !0,
      preserveDrawingBuffer: c = !1,
      powerPreference: h = "default",
      failIfMajorPerformanceCaveat: d = !1
    } = e;
    this.isWebGLRenderer = !0;
    let p;
    n !== null ? p = n.getContextAttributes().alpha : p = o;
    const m = new Uint32Array(4), g = new Int32Array(4);
    let v = null, f = null;
    const u = [], b = [];
    this.domElement = t, this.debug = {
      /**
       * Enables error checking and reporting when shader programs are being compiled
       * @type {boolean}
       */
      checkShaderErrors: !0,
      /**
       * Callback for custom error reporting.
       * @type {?Function}
       */
      onShaderError: null
    }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this._outputColorSpace = ht, this._useLegacyLights = !1, this.toneMapping = ln, this.toneMappingExposure = 1;
    const S = this;
    let R = !1, D = 0, C = 0, A = null, W = -1, x = null;
    const y = new $e(), z = new $e();
    let Z = null;
    const re = new Xe(0);
    let L = 0, F = t.width, V = t.height, Y = 1, X = null, k = null;
    const q = new $e(0, 0, F, V), Q = new $e(0, 0, F, V);
    let ce = !1;
    const H = new cs();
    let j = !1, oe = !1, ve = null;
    const _e = new Qe(), we = new Ie(), Ae = new P(), ge = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: !0 };
    function Pe() {
      return A === null ? Y : 1;
    }
    let N = n;
    function rt(E, U) {
      for (let B = 0; B < E.length; B++) {
        const G = E[B], O = t.getContext(G, U);
        if (O !== null) return O;
      }
      return null;
    }
    try {
      const E = {
        alpha: !0,
        depth: r,
        stencil: s,
        antialias: a,
        premultipliedAlpha: l,
        preserveDrawingBuffer: c,
        powerPreference: h,
        failIfMajorPerformanceCaveat: d
      };
      if ("setAttribute" in t && t.setAttribute("data-engine", `three.js r${ss}`), t.addEventListener("webglcontextlost", te, !1), t.addEventListener("webglcontextrestored", w, !1), t.addEventListener("webglcontextcreationerror", ie, !1), N === null) {
        const U = ["webgl2", "webgl", "experimental-webgl"];
        if (S.isWebGL1Renderer === !0 && U.shift(), N = rt(U, E), N === null)
          throw rt(U) ? new Error("Error creating WebGL context with your selected attributes.") : new Error("Error creating WebGL context.");
      }
      typeof WebGLRenderingContext < "u" && N instanceof WebGLRenderingContext && console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."), N.getShaderPrecisionFormat === void 0 && (N.getShaderPrecisionFormat = function() {
        return { rangeMin: 1, rangeMax: 1, precision: 1 };
      });
    } catch (E) {
      throw console.error("THREE.WebGLRenderer: " + E.message), E;
    }
    let Me, Re, pe, je, be, M, _, I, $, K, J, me, ae, he, ye, Fe, ee, Ye, ze, De, Ee, ue, T, ne;
    function xe() {
      Me = new od(N), Re = new td(N, Me, e), Me.init(Re), ue = new Yf(N, Me, Re), pe = new Xf(N, Me, Re), je = new ud(N), be = new Pf(), M = new qf(N, Me, pe, be, Re, ue, je), _ = new id(S), I = new ad(S), $ = new vc(N, Re), T = new Qh(N, Me, $, Re), K = new ld(N, $, je, T), J = new pd(N, K, $, je), ze = new fd(N, Re, M), Fe = new nd(be), me = new Lf(S, _, I, Me, Re, T, Fe), ae = new $f(S, be), he = new Uf(), ye = new zf(Me, Re), Ye = new Jh(S, _, I, pe, J, p, l), ee = new Wf(S, J, Re), ne = new Jf(N, je, Re, pe), De = new ed(N, Me, je, Re), Ee = new cd(N, Me, je, Re), je.programs = me.programs, S.capabilities = Re, S.extensions = Me, S.properties = be, S.renderLists = he, S.shadowMap = ee, S.state = pe, S.info = je;
    }
    xe();
    const fe = new Zf(S, N);
    this.xr = fe, this.getContext = function() {
      return N;
    }, this.getContextAttributes = function() {
      return N.getContextAttributes();
    }, this.forceContextLoss = function() {
      const E = Me.get("WEBGL_lose_context");
      E && E.loseContext();
    }, this.forceContextRestore = function() {
      const E = Me.get("WEBGL_lose_context");
      E && E.restoreContext();
    }, this.getPixelRatio = function() {
      return Y;
    }, this.setPixelRatio = function(E) {
      E !== void 0 && (Y = E, this.setSize(F, V, !1));
    }, this.getSize = function(E) {
      return E.set(F, V);
    }, this.setSize = function(E, U, B = !0) {
      if (fe.isPresenting) {
        console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");
        return;
      }
      F = E, V = U, t.width = Math.floor(E * Y), t.height = Math.floor(U * Y), B === !0 && (t.style.width = E + "px", t.style.height = U + "px"), this.setViewport(0, 0, E, U);
    }, this.getDrawingBufferSize = function(E) {
      return E.set(F * Y, V * Y).floor();
    }, this.setDrawingBufferSize = function(E, U, B) {
      F = E, V = U, Y = B, t.width = Math.floor(E * B), t.height = Math.floor(U * B), this.setViewport(0, 0, E, U);
    }, this.getCurrentViewport = function(E) {
      return E.copy(y);
    }, this.getViewport = function(E) {
      return E.copy(q);
    }, this.setViewport = function(E, U, B, G) {
      E.isVector4 ? q.set(E.x, E.y, E.z, E.w) : q.set(E, U, B, G), pe.viewport(y.copy(q).multiplyScalar(Y).floor());
    }, this.getScissor = function(E) {
      return E.copy(Q);
    }, this.setScissor = function(E, U, B, G) {
      E.isVector4 ? Q.set(E.x, E.y, E.z, E.w) : Q.set(E, U, B, G), pe.scissor(z.copy(Q).multiplyScalar(Y).floor());
    }, this.getScissorTest = function() {
      return ce;
    }, this.setScissorTest = function(E) {
      pe.setScissorTest(ce = E);
    }, this.setOpaqueSort = function(E) {
      X = E;
    }, this.setTransparentSort = function(E) {
      k = E;
    }, this.getClearColor = function(E) {
      return E.copy(Ye.getClearColor());
    }, this.setClearColor = function() {
      Ye.setClearColor.apply(Ye, arguments);
    }, this.getClearAlpha = function() {
      return Ye.getClearAlpha();
    }, this.setClearAlpha = function() {
      Ye.setClearAlpha.apply(Ye, arguments);
    }, this.clear = function(E = !0, U = !0, B = !0) {
      let G = 0;
      if (E) {
        let O = !1;
        if (A !== null) {
          const de = A.texture.format;
          O = de === mo || de === po || de === fo;
        }
        if (O) {
          const de = A.texture.type, Se = de === cn || de === sn || de === as || de === En || de === uo || de === ho, Le = Ye.getClearColor(), Ue = Ye.getClearAlpha(), Ge = Le.r, Ne = Le.g, Oe = Le.b;
          Se ? (m[0] = Ge, m[1] = Ne, m[2] = Oe, m[3] = Ue, N.clearBufferuiv(N.COLOR, 0, m)) : (g[0] = Ge, g[1] = Ne, g[2] = Oe, g[3] = Ue, N.clearBufferiv(N.COLOR, 0, g));
        } else
          G |= N.COLOR_BUFFER_BIT;
      }
      U && (G |= N.DEPTH_BUFFER_BIT), B && (G |= N.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), N.clear(G);
    }, this.clearColor = function() {
      this.clear(!0, !1, !1);
    }, this.clearDepth = function() {
      this.clear(!1, !0, !1);
    }, this.clearStencil = function() {
      this.clear(!1, !1, !0);
    }, this.dispose = function() {
      t.removeEventListener("webglcontextlost", te, !1), t.removeEventListener("webglcontextrestored", w, !1), t.removeEventListener("webglcontextcreationerror", ie, !1), he.dispose(), ye.dispose(), be.dispose(), _.dispose(), I.dispose(), J.dispose(), T.dispose(), ne.dispose(), me.dispose(), fe.dispose(), fe.removeEventListener("sessionstart", nt), fe.removeEventListener("sessionend", qe), ve && (ve.dispose(), ve = null), st.stop();
    };
    function te(E) {
      E.preventDefault(), console.log("THREE.WebGLRenderer: Context Lost."), R = !0;
    }
    function w() {
      console.log("THREE.WebGLRenderer: Context Restored."), R = !1;
      const E = je.autoReset, U = ee.enabled, B = ee.autoUpdate, G = ee.needsUpdate, O = ee.type;
      xe(), je.autoReset = E, ee.enabled = U, ee.autoUpdate = B, ee.needsUpdate = G, ee.type = O;
    }
    function ie(E) {
      console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ", E.statusMessage);
    }
    function le(E) {
      const U = E.target;
      U.removeEventListener("dispose", le), Ce(U);
    }
    function Ce(E) {
      Te(E), be.remove(E);
    }
    function Te(E) {
      const U = be.get(E).programs;
      U !== void 0 && (U.forEach(function(B) {
        me.releaseProgram(B);
      }), E.isShaderMaterial && me.releaseShaderCache(E));
    }
    this.renderBufferDirect = function(E, U, B, G, O, de) {
      U === null && (U = ge);
      const Se = O.isMesh && O.matrixWorld.determinant() < 0, Le = ko(E, U, B, G, O);
      pe.setMaterial(G, Se);
      let Ue = B.index, Ge = 1;
      if (G.wireframe === !0) {
        if (Ue = K.getWireframeAttribute(B), Ue === void 0) return;
        Ge = 2;
      }
      const Ne = B.drawRange, Oe = B.attributes.position;
      let it = Ne.start * Ge, St = (Ne.start + Ne.count) * Ge;
      de !== null && (it = Math.max(it, de.start * Ge), St = Math.min(St, (de.start + de.count) * Ge)), Ue !== null ? (it = Math.max(it, 0), St = Math.min(St, Ue.count)) : Oe != null && (it = Math.max(it, 0), St = Math.min(St, Oe.count));
      const ct = St - it;
      if (ct < 0 || ct === 1 / 0) return;
      T.setup(O, G, Le, B, Ue);
      let Vt, Je = De;
      if (Ue !== null && (Vt = $.get(Ue), Je = Ee, Je.setIndex(Vt)), O.isMesh)
        G.wireframe === !0 ? (pe.setLineWidth(G.wireframeLinewidth * Pe()), Je.setMode(N.LINES)) : Je.setMode(N.TRIANGLES);
      else if (O.isLine) {
        let He = G.linewidth;
        He === void 0 && (He = 1), pe.setLineWidth(He * Pe()), O.isLineSegments ? Je.setMode(N.LINES) : O.isLineLoop ? Je.setMode(N.LINE_LOOP) : Je.setMode(N.LINE_STRIP);
      } else O.isPoints ? Je.setMode(N.POINTS) : O.isSprite && Je.setMode(N.TRIANGLES);
      if (O.isBatchedMesh)
        Je.renderMultiDraw(O._multiDrawStarts, O._multiDrawCounts, O._multiDrawCount);
      else if (O.isInstancedMesh)
        Je.renderInstances(it, ct, O.count);
      else if (B.isInstancedBufferGeometry) {
        const He = B._maxInstanceCount !== void 0 ? B._maxInstanceCount : 1 / 0, lr = Math.min(B.instanceCount, He);
        Je.renderInstances(it, ct, lr);
      } else
        Je.render(it, ct);
    };
    function ke(E, U, B) {
      E.transparent === !0 && E.side === Kt && E.forceSinglePass === !1 ? (E.side = Mt, E.needsUpdate = !0, Ei(E, U, B), E.side = un, E.needsUpdate = !0, Ei(E, U, B), E.side = Kt) : Ei(E, U, B);
    }
    this.compile = function(E, U, B = null) {
      B === null && (B = E), f = ye.get(B), f.init(), b.push(f), B.traverseVisible(function(O) {
        O.isLight && O.layers.test(U.layers) && (f.pushLight(O), O.castShadow && f.pushShadow(O));
      }), E !== B && E.traverseVisible(function(O) {
        O.isLight && O.layers.test(U.layers) && (f.pushLight(O), O.castShadow && f.pushShadow(O));
      }), f.setupLights(S._useLegacyLights);
      const G = /* @__PURE__ */ new Set();
      return E.traverse(function(O) {
        const de = O.material;
        if (de)
          if (Array.isArray(de))
            for (let Se = 0; Se < de.length; Se++) {
              const Le = de[Se];
              ke(Le, B, O), G.add(Le);
            }
          else
            ke(de, B, O), G.add(de);
      }), b.pop(), f = null, G;
    }, this.compileAsync = function(E, U, B = null) {
      const G = this.compile(E, U, B);
      return new Promise((O) => {
        function de() {
          if (G.forEach(function(Se) {
            be.get(Se).currentProgram.isReady() && G.delete(Se);
          }), G.size === 0) {
            O(E);
            return;
          }
          setTimeout(de, 10);
        }
        Me.get("KHR_parallel_shader_compile") !== null ? de() : setTimeout(de, 10);
      });
    };
    let We = null;
    function et(E) {
      We && We(E);
    }
    function nt() {
      st.stop();
    }
    function qe() {
      st.start();
    }
    const st = new Do();
    st.setAnimationLoop(et), typeof self < "u" && st.setContext(self), this.setAnimationLoop = function(E) {
      We = E, fe.setAnimationLoop(E), E === null ? st.stop() : st.start();
    }, fe.addEventListener("sessionstart", nt), fe.addEventListener("sessionend", qe), this.render = function(E, U) {
      if (U !== void 0 && U.isCamera !== !0) {
        console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");
        return;
      }
      if (R === !0) return;
      E.matrixWorldAutoUpdate === !0 && E.updateMatrixWorld(), U.parent === null && U.matrixWorldAutoUpdate === !0 && U.updateMatrixWorld(), fe.enabled === !0 && fe.isPresenting === !0 && (fe.cameraAutoUpdate === !0 && fe.updateCamera(U), U = fe.getCamera()), E.isScene === !0 && E.onBeforeRender(S, E, U, A), f = ye.get(E, b.length), f.init(), b.push(f), _e.multiplyMatrices(U.projectionMatrix, U.matrixWorldInverse), H.setFromProjectionMatrix(_e), oe = this.localClippingEnabled, j = Fe.init(this.clippingPlanes, oe), v = he.get(E, u.length), v.init(), u.push(v), zt(E, U, 0, S.sortObjects), v.finish(), S.sortObjects === !0 && v.sort(X, k), this.info.render.frame++, j === !0 && Fe.beginShadows();
      const B = f.state.shadowsArray;
      if (ee.render(B, E, U), j === !0 && Fe.endShadows(), this.info.autoReset === !0 && this.info.reset(), Ye.render(v, E), f.setupLights(S._useLegacyLights), U.isArrayCamera) {
        const G = U.cameras;
        for (let O = 0, de = G.length; O < de; O++) {
          const Se = G[O];
          ps(v, E, Se, Se.viewport);
        }
      } else
        ps(v, E, U);
      A !== null && (M.updateMultisampleRenderTarget(A), M.updateRenderTargetMipmap(A)), E.isScene === !0 && E.onAfterRender(S, E, U), T.resetDefaultState(), W = -1, x = null, b.pop(), b.length > 0 ? f = b[b.length - 1] : f = null, u.pop(), u.length > 0 ? v = u[u.length - 1] : v = null;
    };
    function zt(E, U, B, G) {
      if (E.visible === !1) return;
      if (E.layers.test(U.layers)) {
        if (E.isGroup)
          B = E.renderOrder;
        else if (E.isLOD)
          E.autoUpdate === !0 && E.update(U);
        else if (E.isLight)
          f.pushLight(E), E.castShadow && f.pushShadow(E);
        else if (E.isSprite) {
          if (!E.frustumCulled || H.intersectsSprite(E)) {
            G && Ae.setFromMatrixPosition(E.matrixWorld).applyMatrix4(_e);
            const Se = J.update(E), Le = E.material;
            Le.visible && v.push(E, Se, Le, B, Ae.z, null);
          }
        } else if ((E.isMesh || E.isLine || E.isPoints) && (!E.frustumCulled || H.intersectsObject(E))) {
          const Se = J.update(E), Le = E.material;
          if (G && (E.boundingSphere !== void 0 ? (E.boundingSphere === null && E.computeBoundingSphere(), Ae.copy(E.boundingSphere.center)) : (Se.boundingSphere === null && Se.computeBoundingSphere(), Ae.copy(Se.boundingSphere.center)), Ae.applyMatrix4(E.matrixWorld).applyMatrix4(_e)), Array.isArray(Le)) {
            const Ue = Se.groups;
            for (let Ge = 0, Ne = Ue.length; Ge < Ne; Ge++) {
              const Oe = Ue[Ge], it = Le[Oe.materialIndex];
              it && it.visible && v.push(E, Se, it, B, Ae.z, Oe);
            }
          } else Le.visible && v.push(E, Se, Le, B, Ae.z, null);
        }
      }
      const de = E.children;
      for (let Se = 0, Le = de.length; Se < Le; Se++)
        zt(de[Se], U, B, G);
    }
    function ps(E, U, B, G) {
      const O = E.opaque, de = E.transmissive, Se = E.transparent;
      f.setupLightsView(B), j === !0 && Fe.setGlobalState(S.clippingPlanes, B), de.length > 0 && Vo(O, de, U, B), G && pe.viewport(y.copy(G)), O.length > 0 && Si(O, U, B), de.length > 0 && Si(de, U, B), Se.length > 0 && Si(Se, U, B), pe.buffers.depth.setTest(!0), pe.buffers.depth.setMask(!0), pe.buffers.color.setMask(!0), pe.setPolygonOffset(!1);
    }
    function Vo(E, U, B, G) {
      if ((B.isScene === !0 ? B.overrideMaterial : null) !== null)
        return;
      const de = Re.isWebGL2;
      ve === null && (ve = new bn(1, 1, {
        generateMipmaps: !0,
        type: Me.has("EXT_color_buffer_half_float") ? gi : cn,
        minFilter: _i,
        samples: de ? 4 : 0
      })), S.getDrawingBufferSize(we), de ? ve.setSize(we.x, we.y) : ve.setSize(is(we.x), is(we.y));
      const Se = S.getRenderTarget();
      S.setRenderTarget(ve), S.getClearColor(re), L = S.getClearAlpha(), L < 1 && S.setClearColor(16777215, 0.5), S.clear();
      const Le = S.toneMapping;
      S.toneMapping = ln, Si(E, B, G), M.updateMultisampleRenderTarget(ve), M.updateRenderTargetMipmap(ve);
      let Ue = !1;
      for (let Ge = 0, Ne = U.length; Ge < Ne; Ge++) {
        const Oe = U[Ge], it = Oe.object, St = Oe.geometry, ct = Oe.material, Vt = Oe.group;
        if (ct.side === Kt && it.layers.test(G.layers)) {
          const Je = ct.side;
          ct.side = Mt, ct.needsUpdate = !0, ms(it, B, G, St, ct, Vt), ct.side = Je, ct.needsUpdate = !0, Ue = !0;
        }
      }
      Ue === !0 && (M.updateMultisampleRenderTarget(ve), M.updateRenderTargetMipmap(ve)), S.setRenderTarget(Se), S.setClearColor(re, L), S.toneMapping = Le;
    }
    function Si(E, U, B) {
      const G = U.isScene === !0 ? U.overrideMaterial : null;
      for (let O = 0, de = E.length; O < de; O++) {
        const Se = E[O], Le = Se.object, Ue = Se.geometry, Ge = G === null ? Se.material : G, Ne = Se.group;
        Le.layers.test(B.layers) && ms(Le, U, B, Ue, Ge, Ne);
      }
    }
    function ms(E, U, B, G, O, de) {
      E.onBeforeRender(S, U, B, G, O, de), E.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse, E.matrixWorld), E.normalMatrix.getNormalMatrix(E.modelViewMatrix), O.onBeforeRender(S, U, B, G, E, de), O.transparent === !0 && O.side === Kt && O.forceSinglePass === !1 ? (O.side = Mt, O.needsUpdate = !0, S.renderBufferDirect(B, U, G, O, E, de), O.side = un, O.needsUpdate = !0, S.renderBufferDirect(B, U, G, O, E, de), O.side = Kt) : S.renderBufferDirect(B, U, G, O, E, de), E.onAfterRender(S, U, B, G, O, de);
    }
    function Ei(E, U, B) {
      U.isScene !== !0 && (U = ge);
      const G = be.get(E), O = f.state.lights, de = f.state.shadowsArray, Se = O.state.version, Le = me.getParameters(E, O.state, de, U, B), Ue = me.getProgramCacheKey(Le);
      let Ge = G.programs;
      G.environment = E.isMeshStandardMaterial ? U.environment : null, G.fog = U.fog, G.envMap = (E.isMeshStandardMaterial ? I : _).get(E.envMap || G.environment), Ge === void 0 && (E.addEventListener("dispose", le), Ge = /* @__PURE__ */ new Map(), G.programs = Ge);
      let Ne = Ge.get(Ue);
      if (Ne !== void 0) {
        if (G.currentProgram === Ne && G.lightsStateVersion === Se)
          return gs(E, Le), Ne;
      } else
        Le.uniforms = me.getUniforms(E), E.onBuild(B, Le, S), E.onBeforeCompile(Le, S), Ne = me.acquireProgram(Le, Ue), Ge.set(Ue, Ne), G.uniforms = Le.uniforms;
      const Oe = G.uniforms;
      return (!E.isShaderMaterial && !E.isRawShaderMaterial || E.clipping === !0) && (Oe.clippingPlanes = Fe.uniform), gs(E, Le), G.needsLights = Xo(E), G.lightsStateVersion = Se, G.needsLights && (Oe.ambientLightColor.value = O.state.ambient, Oe.lightProbe.value = O.state.probe, Oe.directionalLights.value = O.state.directional, Oe.directionalLightShadows.value = O.state.directionalShadow, Oe.spotLights.value = O.state.spot, Oe.spotLightShadows.value = O.state.spotShadow, Oe.rectAreaLights.value = O.state.rectArea, Oe.ltc_1.value = O.state.rectAreaLTC1, Oe.ltc_2.value = O.state.rectAreaLTC2, Oe.pointLights.value = O.state.point, Oe.pointLightShadows.value = O.state.pointShadow, Oe.hemisphereLights.value = O.state.hemi, Oe.directionalShadowMap.value = O.state.directionalShadowMap, Oe.directionalShadowMatrix.value = O.state.directionalShadowMatrix, Oe.spotShadowMap.value = O.state.spotShadowMap, Oe.spotLightMatrix.value = O.state.spotLightMatrix, Oe.spotLightMap.value = O.state.spotLightMap, Oe.pointShadowMap.value = O.state.pointShadowMap, Oe.pointShadowMatrix.value = O.state.pointShadowMatrix), G.currentProgram = Ne, G.uniformsList = null, Ne;
    }
    function _s(E) {
      if (E.uniformsList === null) {
        const U = E.currentProgram.getUniforms();
        E.uniformsList = Zi.seqWithValue(U.seq, E.uniforms);
      }
      return E.uniformsList;
    }
    function gs(E, U) {
      const B = be.get(E);
      B.outputColorSpace = U.outputColorSpace, B.batching = U.batching, B.instancing = U.instancing, B.instancingColor = U.instancingColor, B.skinning = U.skinning, B.morphTargets = U.morphTargets, B.morphNormals = U.morphNormals, B.morphColors = U.morphColors, B.morphTargetsCount = U.morphTargetsCount, B.numClippingPlanes = U.numClippingPlanes, B.numIntersection = U.numClipIntersection, B.vertexAlphas = U.vertexAlphas, B.vertexTangents = U.vertexTangents, B.toneMapping = U.toneMapping;
    }
    function ko(E, U, B, G, O) {
      U.isScene !== !0 && (U = ge), M.resetTextureUnits();
      const de = U.fog, Se = G.isMeshStandardMaterial ? U.environment : null, Le = A === null ? S.outputColorSpace : A.isXRRenderTarget === !0 ? A.texture.colorSpace : $t, Ue = (G.isMeshStandardMaterial ? I : _).get(G.envMap || Se), Ge = G.vertexColors === !0 && !!B.attributes.color && B.attributes.color.itemSize === 4, Ne = !!B.attributes.tangent && (!!G.normalMap || G.anisotropy > 0), Oe = !!B.morphAttributes.position, it = !!B.morphAttributes.normal, St = !!B.morphAttributes.color;
      let ct = ln;
      G.toneMapped && (A === null || A.isXRRenderTarget === !0) && (ct = S.toneMapping);
      const Vt = B.morphAttributes.position || B.morphAttributes.normal || B.morphAttributes.color, Je = Vt !== void 0 ? Vt.length : 0, He = be.get(G), lr = f.state.lights;
      if (j === !0 && (oe === !0 || E !== x)) {
        const At = E === x && G.id === W;
        Fe.setState(G, E, At);
      }
      let tt = !1;
      G.version === He.__version ? (He.needsLights && He.lightsStateVersion !== lr.state.version || He.outputColorSpace !== Le || O.isBatchedMesh && He.batching === !1 || !O.isBatchedMesh && He.batching === !0 || O.isInstancedMesh && He.instancing === !1 || !O.isInstancedMesh && He.instancing === !0 || O.isSkinnedMesh && He.skinning === !1 || !O.isSkinnedMesh && He.skinning === !0 || O.isInstancedMesh && He.instancingColor === !0 && O.instanceColor === null || O.isInstancedMesh && He.instancingColor === !1 && O.instanceColor !== null || He.envMap !== Ue || G.fog === !0 && He.fog !== de || He.numClippingPlanes !== void 0 && (He.numClippingPlanes !== Fe.numPlanes || He.numIntersection !== Fe.numIntersection) || He.vertexAlphas !== Ge || He.vertexTangents !== Ne || He.morphTargets !== Oe || He.morphNormals !== it || He.morphColors !== St || He.toneMapping !== ct || Re.isWebGL2 === !0 && He.morphTargetsCount !== Je) && (tt = !0) : (tt = !0, He.__version = G.version);
      let dn = He.currentProgram;
      tt === !0 && (dn = Ei(G, U, O));
      let vs = !1, si = !1, cr = !1;
      const ft = dn.getUniforms(), fn = He.uniforms;
      if (pe.useProgram(dn.program) && (vs = !0, si = !0, cr = !0), G.id !== W && (W = G.id, si = !0), vs || x !== E) {
        ft.setValue(N, "projectionMatrix", E.projectionMatrix), ft.setValue(N, "viewMatrix", E.matrixWorldInverse);
        const At = ft.map.cameraPosition;
        At !== void 0 && At.setValue(N, Ae.setFromMatrixPosition(E.matrixWorld)), Re.logarithmicDepthBuffer && ft.setValue(
          N,
          "logDepthBufFC",
          2 / (Math.log(E.far + 1) / Math.LN2)
        ), (G.isMeshPhongMaterial || G.isMeshToonMaterial || G.isMeshLambertMaterial || G.isMeshBasicMaterial || G.isMeshStandardMaterial || G.isShaderMaterial) && ft.setValue(N, "isOrthographic", E.isOrthographicCamera === !0), x !== E && (x = E, si = !0, cr = !0);
      }
      if (O.isSkinnedMesh) {
        ft.setOptional(N, O, "bindMatrix"), ft.setOptional(N, O, "bindMatrixInverse");
        const At = O.skeleton;
        At && (Re.floatVertexTextures ? (At.boneTexture === null && At.computeBoneTexture(), ft.setValue(N, "boneTexture", At.boneTexture, M)) : console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."));
      }
      O.isBatchedMesh && (ft.setOptional(N, O, "batchingTexture"), ft.setValue(N, "batchingTexture", O._matricesTexture, M));
      const ur = B.morphAttributes;
      if ((ur.position !== void 0 || ur.normal !== void 0 || ur.color !== void 0 && Re.isWebGL2 === !0) && ze.update(O, B, dn), (si || He.receiveShadow !== O.receiveShadow) && (He.receiveShadow = O.receiveShadow, ft.setValue(N, "receiveShadow", O.receiveShadow)), G.isMeshGouraudMaterial && G.envMap !== null && (fn.envMap.value = Ue, fn.flipEnvMap.value = Ue.isCubeTexture && Ue.isRenderTargetTexture === !1 ? -1 : 1), si && (ft.setValue(N, "toneMappingExposure", S.toneMappingExposure), He.needsLights && Wo(fn, cr), de && G.fog === !0 && ae.refreshFogUniforms(fn, de), ae.refreshMaterialUniforms(fn, G, Y, V, ve), Zi.upload(N, _s(He), fn, M)), G.isShaderMaterial && G.uniformsNeedUpdate === !0 && (Zi.upload(N, _s(He), fn, M), G.uniformsNeedUpdate = !1), G.isSpriteMaterial && ft.setValue(N, "center", O.center), ft.setValue(N, "modelViewMatrix", O.modelViewMatrix), ft.setValue(N, "normalMatrix", O.normalMatrix), ft.setValue(N, "modelMatrix", O.matrixWorld), G.isShaderMaterial || G.isRawShaderMaterial) {
        const At = G.uniformsGroups;
        for (let hr = 0, qo = At.length; hr < qo; hr++)
          if (Re.isWebGL2) {
            const xs = At[hr];
            ne.update(xs, dn), ne.bind(xs, dn);
          } else
            console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.");
      }
      return dn;
    }
    function Wo(E, U) {
      E.ambientLightColor.needsUpdate = U, E.lightProbe.needsUpdate = U, E.directionalLights.needsUpdate = U, E.directionalLightShadows.needsUpdate = U, E.pointLights.needsUpdate = U, E.pointLightShadows.needsUpdate = U, E.spotLights.needsUpdate = U, E.spotLightShadows.needsUpdate = U, E.rectAreaLights.needsUpdate = U, E.hemisphereLights.needsUpdate = U;
    }
    function Xo(E) {
      return E.isMeshLambertMaterial || E.isMeshToonMaterial || E.isMeshPhongMaterial || E.isMeshStandardMaterial || E.isShadowMaterial || E.isShaderMaterial && E.lights === !0;
    }
    this.getActiveCubeFace = function() {
      return D;
    }, this.getActiveMipmapLevel = function() {
      return C;
    }, this.getRenderTarget = function() {
      return A;
    }, this.setRenderTargetTextures = function(E, U, B) {
      be.get(E.texture).__webglTexture = U, be.get(E.depthTexture).__webglTexture = B;
      const G = be.get(E);
      G.__hasExternalTextures = !0, G.__hasExternalTextures && (G.__autoAllocateDepthBuffer = B === void 0, G.__autoAllocateDepthBuffer || Me.has("WEBGL_multisampled_render_to_texture") === !0 && (console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"), G.__useRenderToTexture = !1));
    }, this.setRenderTargetFramebuffer = function(E, U) {
      const B = be.get(E);
      B.__webglFramebuffer = U, B.__useDefaultFramebuffer = U === void 0;
    }, this.setRenderTarget = function(E, U = 0, B = 0) {
      A = E, D = U, C = B;
      let G = !0, O = null, de = !1, Se = !1;
      if (E) {
        const Ue = be.get(E);
        Ue.__useDefaultFramebuffer !== void 0 ? (pe.bindFramebuffer(N.FRAMEBUFFER, null), G = !1) : Ue.__webglFramebuffer === void 0 ? M.setupRenderTarget(E) : Ue.__hasExternalTextures && M.rebindTextures(E, be.get(E.texture).__webglTexture, be.get(E.depthTexture).__webglTexture);
        const Ge = E.texture;
        (Ge.isData3DTexture || Ge.isDataArrayTexture || Ge.isCompressedArrayTexture) && (Se = !0);
        const Ne = be.get(E).__webglFramebuffer;
        E.isWebGLCubeRenderTarget ? (Array.isArray(Ne[U]) ? O = Ne[U][B] : O = Ne[U], de = !0) : Re.isWebGL2 && E.samples > 0 && M.useMultisampledRTT(E) === !1 ? O = be.get(E).__webglMultisampledFramebuffer : Array.isArray(Ne) ? O = Ne[B] : O = Ne, y.copy(E.viewport), z.copy(E.scissor), Z = E.scissorTest;
      } else
        y.copy(q).multiplyScalar(Y).floor(), z.copy(Q).multiplyScalar(Y).floor(), Z = ce;
      if (pe.bindFramebuffer(N.FRAMEBUFFER, O) && Re.drawBuffers && G && pe.drawBuffers(E, O), pe.viewport(y), pe.scissor(z), pe.setScissorTest(Z), de) {
        const Ue = be.get(E.texture);
        N.framebufferTexture2D(N.FRAMEBUFFER, N.COLOR_ATTACHMENT0, N.TEXTURE_CUBE_MAP_POSITIVE_X + U, Ue.__webglTexture, B);
      } else if (Se) {
        const Ue = be.get(E.texture), Ge = U || 0;
        N.framebufferTextureLayer(N.FRAMEBUFFER, N.COLOR_ATTACHMENT0, Ue.__webglTexture, B || 0, Ge);
      }
      W = -1;
    }, this.readRenderTargetPixels = function(E, U, B, G, O, de, Se) {
      if (!(E && E.isWebGLRenderTarget)) {
        console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
        return;
      }
      let Le = be.get(E).__webglFramebuffer;
      if (E.isWebGLCubeRenderTarget && Se !== void 0 && (Le = Le[Se]), Le) {
        pe.bindFramebuffer(N.FRAMEBUFFER, Le);
        try {
          const Ue = E.texture, Ge = Ue.format, Ne = Ue.type;
          if (Ge !== Ft && ue.convert(Ge) !== N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");
            return;
          }
          const Oe = Ne === gi && (Me.has("EXT_color_buffer_half_float") || Re.isWebGL2 && Me.has("EXT_color_buffer_float"));
          if (Ne !== cn && ue.convert(Ne) !== N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE) && // Edge and Chrome Mac < 52 (#9513)
          !(Ne === an && (Re.isWebGL2 || Me.has("OES_texture_float") || Me.has("WEBGL_color_buffer_float"))) && // Chrome Mac >= 52 and Firefox
          !Oe) {
            console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");
            return;
          }
          U >= 0 && U <= E.width - G && B >= 0 && B <= E.height - O && N.readPixels(U, B, G, O, ue.convert(Ge), ue.convert(Ne), de);
        } finally {
          const Ue = A !== null ? be.get(A).__webglFramebuffer : null;
          pe.bindFramebuffer(N.FRAMEBUFFER, Ue);
        }
      }
    }, this.copyFramebufferToTexture = function(E, U, B = 0) {
      const G = Math.pow(2, -B), O = Math.floor(U.image.width * G), de = Math.floor(U.image.height * G);
      M.setTexture2D(U, 0), N.copyTexSubImage2D(N.TEXTURE_2D, B, 0, 0, E.x, E.y, O, de), pe.unbindTexture();
    }, this.copyTextureToTexture = function(E, U, B, G = 0) {
      const O = U.image.width, de = U.image.height, Se = ue.convert(B.format), Le = ue.convert(B.type);
      M.setTexture2D(B, 0), N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL, B.flipY), N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL, B.premultiplyAlpha), N.pixelStorei(N.UNPACK_ALIGNMENT, B.unpackAlignment), U.isDataTexture ? N.texSubImage2D(N.TEXTURE_2D, G, E.x, E.y, O, de, Se, Le, U.image.data) : U.isCompressedTexture ? N.compressedTexSubImage2D(N.TEXTURE_2D, G, E.x, E.y, U.mipmaps[0].width, U.mipmaps[0].height, Se, U.mipmaps[0].data) : N.texSubImage2D(N.TEXTURE_2D, G, E.x, E.y, Se, Le, U.image), G === 0 && B.generateMipmaps && N.generateMipmap(N.TEXTURE_2D), pe.unbindTexture();
    }, this.copyTextureToTexture3D = function(E, U, B, G, O = 0) {
      if (S.isWebGL1Renderer) {
        console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");
        return;
      }
      const de = E.max.x - E.min.x + 1, Se = E.max.y - E.min.y + 1, Le = E.max.z - E.min.z + 1, Ue = ue.convert(G.format), Ge = ue.convert(G.type);
      let Ne;
      if (G.isData3DTexture)
        M.setTexture3D(G, 0), Ne = N.TEXTURE_3D;
      else if (G.isDataArrayTexture || G.isCompressedArrayTexture)
        M.setTexture2DArray(G, 0), Ne = N.TEXTURE_2D_ARRAY;
      else {
        console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");
        return;
      }
      N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL, G.flipY), N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL, G.premultiplyAlpha), N.pixelStorei(N.UNPACK_ALIGNMENT, G.unpackAlignment);
      const Oe = N.getParameter(N.UNPACK_ROW_LENGTH), it = N.getParameter(N.UNPACK_IMAGE_HEIGHT), St = N.getParameter(N.UNPACK_SKIP_PIXELS), ct = N.getParameter(N.UNPACK_SKIP_ROWS), Vt = N.getParameter(N.UNPACK_SKIP_IMAGES), Je = B.isCompressedTexture ? B.mipmaps[O] : B.image;
      N.pixelStorei(N.UNPACK_ROW_LENGTH, Je.width), N.pixelStorei(N.UNPACK_IMAGE_HEIGHT, Je.height), N.pixelStorei(N.UNPACK_SKIP_PIXELS, E.min.x), N.pixelStorei(N.UNPACK_SKIP_ROWS, E.min.y), N.pixelStorei(N.UNPACK_SKIP_IMAGES, E.min.z), B.isDataTexture || B.isData3DTexture ? N.texSubImage3D(Ne, O, U.x, U.y, U.z, de, Se, Le, Ue, Ge, Je.data) : B.isCompressedArrayTexture ? (console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."), N.compressedTexSubImage3D(Ne, O, U.x, U.y, U.z, de, Se, Le, Ue, Je.data)) : N.texSubImage3D(Ne, O, U.x, U.y, U.z, de, Se, Le, Ue, Ge, Je), N.pixelStorei(N.UNPACK_ROW_LENGTH, Oe), N.pixelStorei(N.UNPACK_IMAGE_HEIGHT, it), N.pixelStorei(N.UNPACK_SKIP_PIXELS, St), N.pixelStorei(N.UNPACK_SKIP_ROWS, ct), N.pixelStorei(N.UNPACK_SKIP_IMAGES, Vt), O === 0 && G.generateMipmaps && N.generateMipmap(Ne), pe.unbindTexture();
    }, this.initTexture = function(E) {
      E.isCubeTexture ? M.setTextureCube(E, 0) : E.isData3DTexture ? M.setTexture3D(E, 0) : E.isDataArrayTexture || E.isCompressedArrayTexture ? M.setTexture2DArray(E, 0) : M.setTexture2D(E, 0), pe.unbindTexture();
    }, this.resetState = function() {
      D = 0, C = 0, A = null, pe.reset(), T.reset();
    }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this }));
  }
  get coordinateSystem() {
    return Zt;
  }
  get outputColorSpace() {
    return this._outputColorSpace;
  }
  set outputColorSpace(e) {
    this._outputColorSpace = e;
    const t = this.getContext();
    t.drawingBufferColorSpace = e === os ? "display-p3" : "srgb", t.unpackColorSpace = Ke.workingColorSpace === sr ? "display-p3" : "srgb";
  }
  get outputEncoding() {
    return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."), this.outputColorSpace === ht ? Tn : go;
  }
  set outputEncoding(e) {
    console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."), this.outputColorSpace = e === Tn ? ht : $t;
  }
  get useLegacyLights() {
    return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights;
  }
  set useLegacyLights(e) {
    console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."), this._useLegacyLights = e;
  }
}
class Qf extends Go {
}
Qf.prototype.isWebGL1Renderer = !0;
class ir {
  constructor(e, t = 25e-5) {
    this.isFogExp2 = !0, this.name = "", this.color = new Xe(e), this.density = t;
  }
  clone() {
    return new ir(this.color, this.density);
  }
  toJSON() {
    return {
      type: "FogExp2",
      name: this.name,
      color: this.color.getHex(),
      density: this.density
    };
  }
}
class Ha extends dt {
  constructor() {
    super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, 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, e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this;
  }
  toJSON(e) {
    const 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;
  }
}
class Va extends Bt {
  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() {
    const e = super.toJSON();
    return e.meshPerAttribute = this.meshPerAttribute, e.isInstancedBufferAttribute = !0, e;
  }
}
const jn = /* @__PURE__ */ new Qe(), ka = /* @__PURE__ */ new Qe(), Yi = [], Wa = /* @__PURE__ */ new Cn(), ep = /* @__PURE__ */ new Qe(), di = /* @__PURE__ */ new Ot(), fi = /* @__PURE__ */ new xi();
class Xa extends Ot {
  constructor(e, t, n) {
    super(e, t), this.isInstancedMesh = !0, this.instanceMatrix = new Va(new Float32Array(n * 16), 16), this.instanceColor = null, this.count = n, this.boundingBox = null, this.boundingSphere = null;
    for (let r = 0; r < n; r++)
      this.setMatrixAt(r, ep);
  }
  computeBoundingBox() {
    const e = this.geometry, t = this.count;
    this.boundingBox === null && (this.boundingBox = new Cn()), e.boundingBox === null && e.computeBoundingBox(), this.boundingBox.makeEmpty();
    for (let n = 0; n < t; n++)
      this.getMatrixAt(n, jn), Wa.copy(e.boundingBox).applyMatrix4(jn), this.boundingBox.union(Wa);
  }
  computeBoundingSphere() {
    const e = this.geometry, t = this.count;
    this.boundingSphere === null && (this.boundingSphere = new xi()), e.boundingSphere === null && e.computeBoundingSphere(), this.boundingSphere.makeEmpty();
    for (let n = 0; n < t; n++)
      this.getMatrixAt(n, jn), fi.copy(e.boundingSphere).applyMatrix4(jn), this.boundingSphere.union(fi);
  }
  copy(e, t) {
    return super.copy(e, t), this.instanceMatrix.copy(e.instanceMatrix), 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) {
    t.fromArray(this.instanceColor.array, e * 3);
  }
  getMatrixAt(e, t) {
    t.fromArray(this.instanceMatrix.array, e * 16);
  }
  raycast(e, t) {
    const n = this.matrixWorld, r = this.count;
    if (di.geometry = this.geometry, di.material = this.material, di.material !== void 0 && (this.boundingSphere === null && this.computeBoundingSphere(), fi.copy(this.boundingSphere), fi.applyMatrix4(n), e.ray.intersectsSphere(fi) !== !1))
      for (let s = 0; s < r; s++) {
        this.getMatrixAt(s, jn), ka.multiplyMatrices(n, jn), di.matrixWorld = ka, di.raycast(e, Yi);
        for (let o = 0, a = Yi.length; o < a; o++) {
          const l = Yi[o];
          l.instanceId = s, l.object = this, t.push(l);
        }
        Yi.length = 0;
      }
  }
  setColorAt(e, t) {
    this.instanceColor === null && (this.instanceColor = new Va(new Float32Array(this.instanceMatrix.count * 3), 3)), t.toArray(this.instanceColor.array, e * 3);
  }
  setMatrixAt(e, t) {
    t.toArray(this.instanceMatrix.array, e * 16);
  }
  updateMorphTargets() {
  }
  dispose() {
    this.dispatchEvent({ type: "dispose" });
  }
}
class ds extends hn {
  constructor(e = 1, t = 0.4, n = 12, r = 48, s = Math.PI * 2) {
    super(), this.type = "TorusGeometry", this.parameters = {
      radius: e,
      tube: t,
      radialSegments: n,
      tubularSegments: r,
      arc: s
    }, n = Math.floor(n), r = Math.floor(r);
    const o = [], a = [], l = [], c = [], h = new P(), d = new P(), p = new P();
    for (let m = 0; m <= n; m++)
      for (let g = 0; g <= r; g++) {
        const v = g / r * s, f = m / n * Math.PI * 2;
        d.x = (e + t * Math.cos(f)) * Math.cos(v), d.y = (e + t * Math.cos(f)) * Math.sin(v), d.z = t * Math.sin(f), a.push(d.x, d.y, d.z), h.x = e * Math.cos(v), h.y = e * Math.sin(v), p.subVectors(d, h).normalize(), l.push(p.x, p.y, p.z), c.push(g / r), c.push(m / n);
      }
    for (let m = 1; m <= n; m++)
      for (let g = 1; g <= r; g++) {
        const v = (r + 1) * m + g - 1, f = (r + 1) * (m - 1) + g - 1, u = (r + 1) * (m - 1) + g, b = (r + 1) * m + g;
        o.push(v, f, b), o.push(f, u, b);
      }
    this.setIndex(o), this.setAttribute("position", new Ht(a, 3)), this.setAttribute("normal", new Ht(l, 3)), this.setAttribute("uv", new Ht(c, 2));
  }
  copy(e) {
    return super.copy(e), this.parameters = Object.assign({}, e.parameters), this;
  }
  static fromJSON(e) {
    return new ds(e.radius, e.tube, e.radialSegments, e.tubularSegments, e.arc);
  }
}
class qa extends Mi {
  constructor(e) {
    super(), this.isMeshStandardMaterial = !0, this.defines = { STANDARD: "" }, this.type = "MeshStandardMaterial", this.color = new Xe(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 Xe(0), this.emissiveIntensity = 1, this.emissiveMap = null, this.bumpMap = null, this.bumpScale = 1, this.normalMap = null, this.normalMapType = vo, this.normalScale = new Ie(1, 1), this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.roughnessMap = null, this.metalnessMap = null, this.alphaMap = null, this.envMap = null, 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.envMapIntensity = e.envMapIntensity, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.flatShading = e.flatShading, this.fog = e.fog, this;
  }
}
class fs extends dt {
  constructor(e, t = 1) {
    super(), this.isLight = !0, this.type = "Light", this.color = new Xe(e), this.intensity = t;
  }
  dispose() {
  }
  copy(e, t) {
    return super.copy(e, t), this.color.copy(e.color), this.intensity = e.intensity, this;
  }
  toJSON(e) {
    const t = super.toJSON(e);
    return t.object.color = this.color.getHex(), t.object.intensity = this.intensity, this.groundColor !== void 0 && (t.object.groundColor = this.groundColor.getHex()), this.distance !== void 0 && (t.object.distance = this.distance), this.angle !== void 0 && (t.object.angle = this.angle), this.decay !== void 0 && (t.object.decay = this.decay), this.penumbra !== void 0 && (t.object.penumbra = this.penumbra), this.shadow !== void 0 && (t.object.shadow = this.shadow.toJSON()), t;
  }
}
const Wr = /* @__PURE__ */ new Qe(), Ya = /* @__PURE__ */ new P(), ja = /* @__PURE__ */ new P();
class Ho {
  constructor(e) {
    this.camera = e, this.bias = 0, this.normalBias = 0, this.radius = 1, this.blurSamples = 8, this.mapSize = new Ie(512, 512), this.map = null, this.mapPass = null, this.matrix = new Qe(), this.autoUpdate = !0, this.needsUpdate = !1, this._frustum = new cs(), this._frameExtents = new Ie(1, 1), this._viewportCount = 1, this._viewports = [
      new $e(0, 0, 1, 1)
    ];
  }
  getViewportCount() {
    return this._viewportCount;
  }
  getFrustum() {
    return this._frustum;
  }
  updateMatrices(e) {
    const t = this.camera, n = this.matrix;
    Ya.setFromMatrixPosition(e.matrixWorld), t.position.copy(Ya), ja.setFromMatrixPosition(e.target.matrixWorld), t.lookAt(ja), t.updateMatrixWorld(), Wr.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Wr), n.set(
      0.5,
      0,
      0,
      0.5,
      0,
      0.5,
      0,
      0.5,
      0,
      0,
      0.5,
      0.5,
      0,
      0,
      0,
      1
    ), n.multiply(Wr);
  }
  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.bias = e.bias, this.radius = e.radius, this.mapSize.copy(e.mapSize), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
  toJSON() {
    const e = {};
    return 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;
  }
}
const Ka = /* @__PURE__ */ new Qe(), pi = /* @__PURE__ */ new P(), Xr = /* @__PURE__ */ new P();
class tp extends Ho {
  constructor() {
    super(new Tt(90, 1, 0.5, 500)), this.isPointLightShadow = !0, this._frameExtents = new Ie(4, 2), this._viewportCount = 6, this._viewports = [
      // These viewports map a cube-map onto a 2D texture with the
      // following orientation:
      //
      //  xzXZ
      //   y Y
      //
      // X - Positive x direction
      // x - Negative x direction
      // Y - Positive y direction
      // y - Negative y direction
      // Z - Positive z direction
      // z - Negative z direction
      // positive X
      new $e(2, 1, 1, 1),
      // negative X
      new $e(0, 1, 1, 1),
      // positive Z
      new $e(3, 1, 1, 1),
      // negative Z
      new $e(1, 1, 1, 1),
      // positive Y
      new $e(3, 0, 1, 1),
      // negative Y
      new $e(1, 0, 1, 1)
    ], this._cubeDirections = [
      new P(1, 0, 0),
      new P(-1, 0, 0),
      new P(0, 0, 1),
      new P(0, 0, -1),
      new P(0, 1, 0),
      new P(0, -1, 0)
    ], this._cubeUps = [
      new P(0, 1, 0),
      new P(0, 1, 0),
      new P(0, 1, 0),
      new P(0, 1, 0),
      new P(0, 0, 1),
      new P(0, 0, -1)
    ];
  }
  updateMatrices(e, t = 0) {
    const n = this.camera, r = this.matrix, s = e.distance || n.far;
    s !== n.far && (n.far = s, n.updateProjectionMatrix()), pi.setFromMatrixPosition(e.matrixWorld), n.position.copy(pi), Xr.copy(n.position), Xr.add(this._cubeDirections[t]), n.up.copy(this._cubeUps[t]), n.lookAt(Xr), n.updateMatrixWorld(), r.makeTranslation(-pi.x, -pi.y, -pi.z), Ka.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse), this._frustum.setFromProjectionMatrix(Ka);
  }
}
class Za extends fs {
  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 tp();
  }
  get power() {
    return this.intensity * 4 * Math.PI;
  }
  set power(e) {
    this.intensity = e / (4 * Math.PI);
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e, t) {
    return super.copy(e, t), this.distance = e.distance, this.decay = e.decay, this.shadow = e.shadow.clone(), this;
  }
}
class np extends Ho {
  constructor() {
    super(new Uo(-5, 5, 5, -5, 0.5, 500)), this.isDirectionalLightShadow = !0;
  }
}
class ip extends fs {
  constructor(e, t) {
    super(e, t), this.isDirectionalLight = !0, this.type = "DirectionalLight", this.position.copy(dt.DEFAULT_UP), this.updateMatrix(), this.target = new dt(), this.shadow = new np();
  }
  dispose() {
    this.shadow.dispose();
  }
  copy(e) {
    return super.copy(e), this.target = e.target.clone(), this.shadow = e.shadow.clone(), this;
  }
}
class rp extends fs {
  constructor(e, t) {
    super(e, t), this.isAmbientLight = !0, this.type = "AmbientLight";
  }
}
class $a {
  constructor(e = 1, t = 0, n = 0) {
    return this.radius = e, this.phi = t, this.theta = n, this;
  }
  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;
  }
  // restrict phi to be between EPS and PI-EPS
  makeSafe() {
    return this.phi = Math.max(1e-6, Math.min(Math.PI - 1e-6, this.phi)), 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(vt(t / this.radius, -1, 1))), this;
  }
  clone() {
    return new this.constructor().copy(this);
  }
}
typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: {
  revision: ss
} }));
typeof window < "u" && (window.__THREE__ ? console.warn("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = ss);
const Ja = { type: "change" }, qr = { type: "start" }, Qa = { type: "end" }, ji = new To(), eo = new rn(), sp = Math.cos(70 * ql.DEG2RAD);
class ap extends Rn {
  constructor(e, t) {
    super(), this.object = e, this.domElement = t, this.domElement.style.touchAction = "none", this.enabled = !0, this.target = new P(), this.cursor = new P(), this.minDistance = 0, this.maxDistance = 1 / 0, this.minZoom = 0, this.maxZoom = 1 / 0, this.minTargetRadius = 0, this.maxTargetRadius = 1 / 0, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -1 / 0, this.maxAzimuthAngle = 1 / 0, this.enableDamping = !1, this.dampingFactor = 0.05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { LEFT: "ArrowLeft", UP: "ArrowUp", RIGHT: "ArrowRight", BOTTOM: "ArrowDown" }, this.mouseButtons = { LEFT: Ln.ROTATE, MIDDLE: Ln.DOLLY, RIGHT: Ln.PAN }, this.touches = { ONE: Pn.ROTATE, TWO: Pn.DOLLY_PAN }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._domElementKeyEvents = null, this.getPolarAngle = function() {
      return a.phi;
    }, this.getAzimuthalAngle = function() {
      return a.theta;
    }, this.getDistance = function() {
      return this.object.position.distanceTo(this.target);
    }, this.listenToKeyEvents = function(T) {
      T.addEventListener("keydown", ye), this._domElementKeyEvents = T;
    }, this.stopListenToKeyEvents = function() {
      this._domElementKeyEvents.removeEventListener("keydown", ye), this._domElementKeyEvents = null;
    }, this.saveState = function() {
      n.target0.copy(n.target), n.position0.copy(n.object.position), n.zoom0 = n.object.zoom;
    }, this.reset = function() {
      n.target.copy(n.target0), n.object.position.copy(n.position0), n.object.zoom = n.zoom0, n.object.updateProjectionMatrix(), n.dispatchEvent(Ja), n.update(), s = r.NONE;
    }, this.update = function() {
      const T = new P(), ne = new An().setFromUnitVectors(e.up, new P(0, 1, 0)), xe = ne.clone().invert(), fe = new P(), te = new An(), w = new P(), ie = 2 * Math.PI;
      return function(Ce = null) {
        const Te = n.object.position;
        T.copy(Te).sub(n.target), T.applyQuaternion(ne), a.setFromVector3(T), n.autoRotate && s === r.NONE && Z(y(Ce)), n.enableDamping ? (a.theta += l.theta * n.dampingFactor, a.phi += l.phi * n.dampingFactor) : (a.theta += l.theta, a.phi += l.phi);
        let ke = n.minAzimuthAngle, We = n.maxAzimuthAngle;
        isFinite(ke) && isFinite(We) && (ke < -Math.PI ? ke += ie : ke > Math.PI && (ke -= ie), We < -Math.PI ? We += ie : We > Math.PI && (We -= ie), ke <= We ? a.theta = Math.max(ke, Math.min(We, a.theta)) : a.theta = a.theta > (ke + We) / 2 ? Math.max(ke, a.theta) : Math.min(We, a.theta)), a.phi = Math.max(n.minPolarAngle, Math.min(n.maxPolarAngle, a.phi)), a.makeSafe(), n.enableDamping === !0 ? n.target.addScaledVector(h, n.dampingFactor) : n.target.add(h), n.target.sub(n.cursor), n.target.clampLength(n.minTargetRadius, n.maxTargetRadius), n.target.add(n.cursor), n.zoomToCursor && C || n.object.isOrthographicCamera ? a.radius = q(a.radius) : a.radius = q(a.radius * c), T.setFromSpherical(a), T.applyQuaternion(xe), Te.copy(n.target).add(T), n.object.lookAt(n.target), n.enableDamping === !0 ? (l.theta *= 1 - n.dampingFactor, l.phi *= 1 - n.dampingFactor, h.multiplyScalar(1 - n.dampingFactor)) : (l.set(0, 0, 0), h.set(0, 0, 0));
        let et = !1;
        if (n.zoomToCursor && C) {
          let nt = null;
          if (n.object.isPerspectiveCamera) {
            const qe = T.length();
            nt = q(qe * c);
            const st = qe - nt;
            n.object.position.addScaledVector(R, st), n.object.updateMatrixWorld();
          } else if (n.object.isOrthographicCamera) {
            const qe = new P(D.x, D.y, 0);
            qe.unproject(n.object), n.object.zoom = Math.max(n.minZoom, Math.min(n.maxZoom, n.object.zoom / c)), n.object.updateProjectionMatrix(), et = !0;
            const st = new P(D.x, D.y, 0);
            st.unproject(n.object), n.object.position.sub(st).add(qe), n.object.updateMatrixWorld(), nt = T.length();
          } else
            console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), n.zoomToCursor = !1;
          nt !== null && (this.screenSpacePanning ? n.target.set(0, 0, -1).transformDirection(n.object.matrix).multiplyScalar(nt).add(n.object.position) : (ji.origin.copy(n.object.position), ji.direction.set(0, 0, -1).transformDirection(n.object.matrix), Math.abs(n.object.up.dot(ji.direction)) < sp ? e.lookAt(n.target) : (eo.setFromNormalAndCoplanarPoint(n.object.up, n.target), ji.intersectPlane(eo, n.target))));
        } else n.object.isOrthographicCamera && (n.object.zoom = Math.max(n.minZoom, Math.min(n.maxZoom, n.object.zoom / c)), n.object.updateProjectionMatrix(), et = !0);
        return c = 1, C = !1, et || fe.distanceToSquared(n.object.position) > o || 8 * (1 - te.dot(n.object.quaternion)) > o || w.distanceToSquared(n.target) > 0 ? (n.dispatchEvent(Ja), fe.copy(n.object.position), te.copy(n.object.quaternion), w.copy(n.target), !0) : !1;
      };
    }(), this.dispose = function() {
      n.domElement.removeEventListener("contextmenu", Ye), n.domElement.removeEventListener("pointerdown", M), n.domElement.removeEventListener("pointercancel", I), n.domElement.removeEventListener("wheel", J), n.domElement.removeEventListener("pointermove", _), n.domElement.removeEventListener("pointerup", I), n._domElementKeyEvents !== null && (n._domElementKeyEvents.removeEventListener("keydown", ye), n._domElementKeyEvents = null);
    };
    const n = this, r = {
      NONE: -1,
      ROTATE: 0,
      DOLLY: 1,
      PAN: 2,
      TOUCH_ROTATE: 3,
      TOUCH_PAN: 4,
      TOUCH_DOLLY_PAN: 5,
      TOUCH_DOLLY_ROTATE: 6
    };
    let s = r.NONE;
    const o = 1e-6, a = new $a(), l = new $a();
    let c = 1;
    const h = new P(), d = new Ie(), p = new Ie(), m = new Ie(), g = new Ie(), v = new Ie(), f = new Ie(), u = new Ie(), b = new Ie(), S = new Ie(), R = new P(), D = new Ie();
    let C = !1;
    const A = [], W = {};
    let x = !1;
    function y(T) {
      return T !== null ? 2 * Math.PI / 60 * n.autoRotateSpeed * T : 2 * Math.PI / 60 / 60 * n.autoRotateSpeed;
    }
    function z(T) {
      const ne = Math.abs(T * 0.01);
      return Math.pow(0.95, n.zoomSpeed * ne);
    }
    function Z(T) {
      l.theta -= T;
    }
    function re(T) {
      l.phi -= T;
    }
    const L = function() {
      const T = new P();
      return function(xe, fe) {
        T.setFromMatrixColumn(fe, 0), T.multiplyScalar(-xe), h.add(T);
      };
    }(), F = function() {
      const T = new P();
      return function(xe, fe) {
        n.screenSpacePanning === !0 ? T.setFromMatrixColumn(fe, 1) : (T.setFromMatrixColumn(fe, 0), T.crossVectors(n.object.up, T)), T.multiplyScalar(xe), h.add(T);
      };
    }(), V = function() {
      const T = new P();
      return function(xe, fe) {
        const te = n.domElement;
        if (n.object.isPerspectiveCamera) {
          const w = n.object.position;
          T.copy(w).sub(n.target);
          let ie = T.length();
          ie *= Math.tan(n.object.fov / 2 * Math.PI / 180), L(2 * xe * ie / te.clientHeight, n.object.matrix), F(2 * fe * ie / te.clientHeight, n.object.matrix);
        } else n.object.isOrthographicCamera ? (L(xe * (n.object.right - n.object.left) / n.object.zoom / te.clientWidth, n.object.matrix), F(fe * (n.object.top - n.object.bottom) / n.object.zoom / te.clientHeight, n.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), n.enablePan = !1);
      };
    }();
    function Y(T) {
      n.object.isPerspectiveCamera || n.object.isOrthographicCamera ? c /= T : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), n.enableZoom = !1);
    }
    function X(T) {
      n.object.isPerspectiveCamera || n.object.isOrthographicCamera ? c *= T : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), n.enableZoom = !1);
    }
    function k(T, ne) {
      if (!n.zoomToCursor)
        return;
      C = !0;
      const xe = n.domElement.getBoundingClientRect(), fe = T - xe.left, te = ne - xe.top, w = xe.width, ie = xe.height;
      D.x = fe / w * 2 - 1, D.y = -(te / ie) * 2 + 1, R.set(D.x, D.y, 1).unproject(n.object).sub(n.object.position).normalize();
    }
    function q(T) {
      return Math.max(n.minDistance, Math.min(n.maxDistance, T));
    }
    function Q(T) {
      d.set(T.clientX, T.clientY);
    }
    function ce(T) {
      k(T.clientX, T.clientX), u.set(T.clientX, T.clientY);
    }
    function H(T) {
      g.set(T.clientX, T.clientY);
    }
    function j(T) {
      p.set(T.clientX, T.clientY), m.subVectors(p, d).multiplyScalar(n.rotateSpeed);
      const ne = n.domElement;
      Z(2 * Math.PI * m.x / ne.clientHeight), re(2 * Math.PI * m.y / ne.clientHeight), d.copy(p), n.update();
    }
    function oe(T) {
      b.set(T.clientX, T.clientY), S.subVectors(b, u), S.y > 0 ? Y(z(S.y)) : S.y < 0 && X(z(S.y)), u.copy(b), n.update();
    }
    function ve(T) {
      v.set(T.clientX, T.clientY), f.subVectors(v, g).multiplyScalar(n.panSpeed), V(f.x, f.y), g.copy(v), n.update();
    }
    function _e(T) {
      k(T.clientX, T.clientY), T.deltaY < 0 ? X(z(T.deltaY)) : T.deltaY > 0 && Y(z(T.deltaY)), n.update();
    }
    function we(T) {
      let ne = !1;
      switch (T.code) {
        case n.keys.UP:
          T.ctrlKey || T.metaKey || T.shiftKey ? re(2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : V(0, n.keyPanSpeed), ne = !0;
          break;
        case n.keys.BOTTOM:
          T.ctrlKey || T.metaKey || T.shiftKey ? re(-2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : V(0, -n.keyPanSpeed), ne = !0;
          break;
        case n.keys.LEFT:
          T.ctrlKey || T.metaKey || T.shiftKey ? Z(2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : V(n.keyPanSpeed, 0), ne = !0;
          break;
        case n.keys.RIGHT:
          T.ctrlKey || T.metaKey || T.shiftKey ? Z(-2 * Math.PI * n.rotateSpeed / n.domElement.clientHeight) : V(-n.keyPanSpeed, 0), ne = !0;
          break;
      }
      ne && (T.preventDefault(), n.update());
    }
    function Ae(T) {
      if (A.length === 1)
        d.set(T.pageX, T.pageY);
      else {
        const ne = ue(T), xe = 0.5 * (T.pageX + ne.x), fe = 0.5 * (T.pageY + ne.y);
        d.set(xe, fe);
      }
    }
    function ge(T) {
      if (A.length === 1)
        g.set(T.pageX, T.pageY);
      else {
        const ne = ue(T), xe = 0.5 * (T.pageX + ne.x), fe = 0.5 * (T.pageY + ne.y);
        g.set(xe, fe);
      }
    }
    function Pe(T) {
      const ne = ue(T), xe = T.pageX - ne.x, fe = T.pageY - ne.y, te = Math.sqrt(xe * xe + fe * fe);
      u.set(0, te);
    }
    function N(T) {
      n.enableZoom && Pe(T), n.enablePan && ge(T);
    }
    function rt(T) {
      n.enableZoom && Pe(T), n.enableRotate && Ae(T);
    }
    function Me(T) {
      if (A.length == 1)
        p.set(T.pageX, T.pageY);
      else {
        const xe = ue(T), fe = 0.5 * (T.pageX + xe.x), te = 0.5 * (T.pageY + xe.y);
        p.set(fe, te);
      }
      m.subVectors(p, d).multiplyScalar(n.rotateSpeed);
      const ne = n.domElement;
      Z(2 * Math.PI * m.x / ne.clientHeight), re(2 * Math.PI * m.y / ne.clientHeight), d.copy(p);
    }
    function Re(T) {
      if (A.length === 1)
        v.set(T.pageX, T.pageY);
      else {
        const ne = ue(T), xe = 0.5 * (T.pageX + ne.x), fe = 0.5 * (T.pageY + ne.y);
        v.set(xe, fe);
      }
      f.subVectors(v, g).multiplyScalar(n.panSpeed), V(f.x, f.y), g.copy(v);
    }
    function pe(T) {
      const ne = ue(T), xe = T.pageX - ne.x, fe = T.pageY - ne.y, te = Math.sqrt(xe * xe + fe * fe);
      b.set(0, te), S.set(0, Math.pow(b.y / u.y, n.zoomSpeed)), Y(S.y), u.copy(b);
      const w = (T.pageX + ne.x) * 0.5, ie = (T.pageY + ne.y) * 0.5;
      k(w, ie);
    }
    function je(T) {
      n.enableZoom && pe(T), n.enablePan && Re(T);
    }
    function be(T) {
      n.enableZoom && pe(T), n.enableRotate && Me(T);
    }
    function M(T) {
      n.enabled !== !1 && (A.length === 0 && (n.domElement.setPointerCapture(T.pointerId), n.domElement.addEventListener("pointermove", _), n.domElement.addEventListener("pointerup", I)), ze(T), T.pointerType === "touch" ? Fe(T) : $(T));
    }
    function _(T) {
      n.enabled !== !1 && (T.pointerType === "touch" ? ee(T) : K(T));
    }
    function I(T) {
      De(T), A.length === 0 && (n.domElement.releasePointerCapture(T.pointerId), n.domElement.removeEventListener("pointermove", _), n.domElement.removeEventListener("pointerup", I)), n.dispatchEvent(Qa), s = r.NONE;
    }
    function $(T) {
      let ne;
      switch (T.button) {
        case 0:
          ne = n.mouseButtons.LEFT;
          break;
        case 1:
          ne = n.mouseButtons.MIDDLE;
          break;
        case 2:
          ne = n.mouseButtons.RIGHT;
          break;
        default:
          ne = -1;
      }
      switch (ne) {
        case Ln.DOLLY:
          if (n.enableZoom === !1) return;
          ce(T), s = r.DOLLY;
          break;
        case Ln.ROTATE:
          if (T.ctrlKey || T.metaKey || T.shiftKey) {
            if (n.enablePan === !1) return;
            H(T), s = r.PAN;
          } else {
            if (n.enableRotate === !1) return;
            Q(T), s = r.ROTATE;
          }
          break;
        case Ln.PAN:
          if (T.ctrlKey || T.metaKey || T.shiftKey) {
            if (n.enableRotate === !1) return;
            Q(T), s = r.ROTATE;
          } else {
            if (n.enablePan === !1) return;
            H(T), s = r.PAN;
          }
          break;
        default:
          s = r.NONE;
      }
      s !== r.NONE && n.dispatchEvent(qr);
    }
    function K(T) {
      switch (s) {
        case r.ROTATE:
          if (n.enableRotate === !1) return;
          j(T);
          break;
        case r.DOLLY:
          if (n.enableZoom === !1) return;
          oe(T);
          break;
        case r.PAN:
          if (n.enablePan === !1) return;
          ve(T);
          break;
      }
    }
    function J(T) {
      n.enabled === !1 || n.enableZoom === !1 || s !== r.NONE || (T.preventDefault(), n.dispatchEvent(qr), _e(me(T)), n.dispatchEvent(Qa));
    }
    function me(T) {
      const ne = T.deltaMode, xe = {
        clientX: T.clientX,
        clientY: T.clientY,
        deltaY: T.deltaY
      };
      switch (ne) {
        case 1:
          xe.deltaY *= 16;
          break;
        case 2:
          xe.deltaY *= 100;
          break;
      }
      return T.ctrlKey && !x && (xe.deltaY *= 10), xe;
    }
    function ae(T) {
      T.key === "Control" && (x = !0, document.addEventListener("keyup", he, { passive: !0, capture: !0 }));
    }
    function he(T) {
      T.key === "Control" && (x = !1, document.removeEventListener("keyup", he, { passive: !0, capture: !0 }));
    }
    function ye(T) {
      n.enabled === !1 || n.enablePan === !1 || we(T);
    }
    function Fe(T) {
      switch (Ee(T), A.length) {
        case 1:
          switch (n.touches.ONE) {
            case Pn.ROTATE:
              if (n.enableRotate === !1) return;
              Ae(T), s = r.TOUCH_ROTATE;
              break;
            case Pn.PAN:
              if (n.enablePan === !1) return;
              ge(T), s = r.TOUCH_PAN;
              break;
            default:
              s = r.NONE;
          }
          break;
        case 2:
          switch (n.touches.TWO) {
            case Pn.DOLLY_PAN:
              if (n.enableZoom === !1 && n.enablePan === !1) return;
              N(T), s = r.TOUCH_DOLLY_PAN;
              break;
            case Pn.DOLLY_ROTATE:
              if (n.enableZoom === !1 && n.enableRotate === !1) return;
              rt(T), s = r.TOUCH_DOLLY_ROTATE;
              break;
            default:
              s = r.NONE;
          }
          break;
        default:
          s = r.NONE;
      }
      s !== r.NONE && n.dispatchEvent(qr);
    }
    function ee(T) {
      switch (Ee(T), s) {
        case r.TOUCH_ROTATE:
          if (n.enableRotate === !1) return;
          Me(T), n.update();
          break;
        case r.TOUCH_PAN:
          if (n.enablePan === !1) return;
          Re(T), n.update();
          break;
        case r.TOUCH_DOLLY_PAN:
          if (n.enableZoom === !1 && n.enablePan === !1) return;
          je(T), n.update();
          break;
        case r.TOUCH_DOLLY_ROTATE:
          if (n.enableZoom === !1 && n.enableRotate === !1) return;
          be(T), n.update();
          break;
        default:
          s = r.NONE;
      }
    }
    function Ye(T) {
      n.enabled !== !1 && T.preventDefault();
    }
    function ze(T) {
      A.push(T.pointerId);
    }
    function De(T) {
      delete W[T.pointerId];
      for (let ne = 0; ne < A.length; ne++)
        if (A[ne] == T.pointerId) {
          A.splice(ne, 1);
          return;
        }
    }
    function Ee(T) {
      let ne = W[T.pointerId];
      ne === void 0 && (ne = new Ie(), W[T.pointerId] = ne), ne.set(T.pageX, T.pageY);
    }
    function ue(T) {
      const ne = T.pointerId === A[0] ? A[1] : A[0];
      return W[ne];
    }
    n.domElement.addEventListener("contextmenu", Ye), n.domElement.addEventListener("pointerdown", M), n.domElement.addEventListener("pointercancel", I), n.domElement.addEventListener("wheel", J, { passive: !1 }), document.addEventListener("keydown", ae, { passive: !0, capture: !0 }), this.update();
  }
}
const op = "_wrapper_1xs2z_1", lp = "_canvasShell_1xs2z_28", cp = "_canvas_1xs2z_28", up = "_viewportLabels_1xs2z_48", hp = "_splitLabel_1xs2z_61", dp = "_controlOverlay_1xs2z_73", fp = "_resolutionCard_1xs2z_83", pp = "_resolutionControl_1xs2z_97", mp = "_slider_1xs2z_105", _p = "_sliderValue_1xs2z_111", Ut = {
  wrapper: op,
  canvasShell: lp,
  canvas: cp,
  viewportLabels: up,
  splitLabel: hp,
  controlOverlay: dp,
  resolutionCard: fp,
  resolutionControl: pp,
  slider: mp,
  sliderValue: _p
}, gp = 24, to = new P(20, 20, 20), no = new P(0, 0, 0), vp = 5e3, Yr = "#f2f0ea", xp = (i, e, t) => Math.min(t, Math.max(e, i)), jr = (i, e, t, n, r = 1) => {
  if (typeof i != "number" || Number.isNaN(i)) return e;
  const s = Math.round(i / r) * r;
  return xp(s, t, n);
};
function io(i) {
  const e = new rp(16777215, 0.65);
  i.add(e);
  const t = new ip(16777215, 1.1);
  t.position.set(20, 50, 20), t.castShadow = !0, t.shadow.mapSize.width = 2048, t.shadow.mapSize.height = 2048, i.add(t);
  const n = new Za(3900150, 1.1, 50);
  n.position.set(-10, 10, -10), i.add(n);
  const r = new Za(16743001, 0.9, 50);
  r.position.set(10, -10, 10), i.add(r);
}
function Mp(i) {
  if (Array.isArray(i)) {
    i.forEach((e) => e.dispose());
    return;
  }
  i.dispose();
}
function ro(i) {
  i.traverse((e) => {
    const t = e;
    t.geometry && t.geometry.dispose(), t.material && Mp(t.material);
  });
}
function yp({
  config: i,
  onComplete: e,
  onProgress: t,
  theme: n,
  className: r
}) {
  const s = i.params ?? {}, o = jr(s.gridSize, 24, 12, 80, 1), a = jr(s.majorRadius, 8, 4, 10, 0.5), l = jr(s.minorRadius, 3, 1, 5, 0.25), [c, h] = Ms(o), [d, p] = Ms({
    layout: "landscape",
    width: 0,
    height: 0
  }), m = dr(null), g = dr(null), v = dr(!1);
  ai(() => {
    const R = m.current;
    if (!R) return;
    const D = () => {
      const A = R.clientWidth, W = R.clientHeight;
      if (!A || !W) return;
      const x = A >= W ? "landscape" : "portrait";
      let y = A, z = W;
      x === "landscape" ? (z = Math.min(W, A * (9 / 16)), y = z * (16 / 9)) : (y = Math.min(A, W / 2), z = y * 2), p({
        layout: x,
        width: y,
        height: z
      });
    }, C = new ResizeObserver(D);
    return C.observe(R), D(), () => {
      C.disconnect();
    };
  }, []), ai(() => {
    h(o), v.current = !1;
  }, [i.id, o, a, l]);
  const f = fr(
    () => Math.max(gp, (a + l + 1.5) * 2),
    [a, l]
  ), u = fr(() => f / c, [f, c]);
  ai(() => {
    t == null || t(c === o ? 0 : 100);
  }, [o, t, c]), ai(() => {
    c === o || v.current || (v.current = !0, e({
      success: !0,
      score: 100,
      data: {
        configId: i.id,
        completedAt: (/* @__PURE__ */ new Date()).toISOString(),
        params: {
          gridSize: c,
          majorRadius: a,
          minorRadius: l
        }
      }
    }));
  }, [i.id, o, a, l, e, c]), ai(() => {
    const R = g.current;
    if (!R) return;
    const D = new Ha(), C = new Ha(), A = new Xe(Yr);
    D.background = A, D.fog = new ir(Yr, 0.02), C.background = A, C.fog = new ir(Yr, 0.02), io(D), io(C);
    const W = new Tt(45, 1, 0.1, 1e3);
    W.position.copy(to);
    const x = new Go({ antialias: !0, alpha: !0 });
    x.shadowMap.enabled = !0, x.shadowMap.type = ao, x.setPixelRatio(Math.min(window.devicePixelRatio, 2)), x.setScissorTest(!0), R.appendChild(x.domElement);
    const y = new ap(W, x.domElement);
    y.enableDamping = !0, y.dampingFactor = 0.05, y.minDistance = 5, y.maxDistance = 100, y.target.copy(no);
    const z = new ds(a, l, 64, 128), Z = new qa({
      color: 3900150,
      roughness: 0.22,
      metalness: 0.1
    }), re = new Ot(z, Z);
    re.castShadow = !0, re.receiveShadow = !0, re.rotation.x = -Math.PI / 2, D.add(re);
    const L = u * 0.12, F = Math.max(u - L, u * 0.2), V = new ii(F, F, F), Y = new qa({
      color: 3900150,
      roughness: 0.22,
      metalness: 0.1
    }), X = new ls({
      color: 0,
      transparent: !0,
      opacity: 0.08,
      wireframe: !0
    }), k = Math.pow(c, 3), q = new Xa(V, Y, k), Q = new Xa(V, X, k), ce = (c - 1) * u / 2, H = new dt();
    q.castShadow = !0, q.receiveShadow = !0, C.add(q), C.add(Q);
    let j = 0, oe = 0;
    for (let be = 0; be < c; be += 1)
      for (let M = 0; M < c; M += 1)
        for (let _ = 0; _ < c; _ += 1) {
          const I = be * u - ce, $ = M * u - ce, K = _ * u - ce, J = Math.sqrt(I * I + K * K) - a, ae = J * J + $ * $ < l * l;
          if (H.position.set(I, $, K), H.updateMatrix(), ae) {
            q.setMatrixAt(j, H.matrix);
            const he = new Xe(), ye = 0.52 + $ / Math.max(c, 1) * 0.18;
            he.setHSL(ye, 0.78, 0.52), q.setColorAt(j, he), j += 1;
            continue;
          }
          Q.setMatrixAt(oe, H.matrix), oe += 1;
        }
    q.count = j, Q.count = oe, q.instanceMatrix.needsUpdate = !0, Q.instanceMatrix.needsUpdate = !0, q.instanceColor && (q.instanceColor.needsUpdate = !0);
    const ve = to.clone(), _e = no.clone();
    let we = !1, Ae = null, ge = 0, Pe = 0;
    const N = () => {
      ge = R.clientWidth, Pe = R.clientHeight, !(!ge || !Pe) && (W.aspect = 1, W.updateProjectionMatrix(), x.setSize(ge, Pe, !1));
    }, rt = new ResizeObserver(N);
    rt.observe(R), N();
    const Me = () => {
      we = !1, Ae !== null && (window.clearTimeout(Ae), Ae = null);
    }, Re = () => {
      Ae = window.setTimeout(() => {
        we = !0;
      }, vp);
    };
    y.addEventListener("start", Me), y.addEventListener("end", Re);
    let pe = 0;
    const je = () => {
      if (pe = window.requestAnimationFrame(je), we && (W.position.lerp(ve, 0.05), y.target.lerp(_e, 0.05), W.position.distanceTo(ve) < 0.1 && y.target.distanceTo(_e) < 0.1 && (we = !1)), re.rotation.z += 2e-3, q.rotation.y += 2e-3, Q.rotation.y += 2e-3, Q.visible = !1, y.update(), !ge || !Pe) return;
      const be = ge >= Pe, M = be ? Math.min(ge / 2, Pe) : Math.min(ge, Pe / 2), _ = be ? (ge - M * 2) / 2 : (ge - M) / 2, I = be ? (Pe - M) / 2 : (Pe - M * 2) / 2, $ = _, K = be ? I : I + M, J = be ? _ + M : _, me = I;
      x.setScissor($, K, M, M), x.setViewport($, K, M, M), x.render(D, W), x.setScissor(J, me, M, M), x.setViewport(J, me, M, M), x.render(C, W);
    };
    return je(), () => {
      window.cancelAnimationFrame(pe), Ae !== null && window.clearTimeout(Ae), rt.disconnect(), y.removeEventListener("start", Me), y.removeEventListener("end", Re), y.dispose(), x.dispose(), ro(D), ro(C), R.removeChild(x.domElement);
    };
  }, [a, l, c, u]);
  const b = fr(
    () => ({
      "--gc-primary": (n == null ? void 0 : n.primary) ?? "var(--color-primary, #45c4b0)",
      "--gc-accent": (n == null ? void 0 : n.accent) ?? "var(--color-accent, #ff7a59)",
      "--gc-bg": (n == null ? void 0 : n.bg) ?? "var(--color-bg, #0d1117)",
      "--gc-bg-secondary": (n == null ? void 0 : n.bgSecondary) ?? "var(--color-bg-secondary, #182237)",
      "--gc-text": (n == null ? void 0 : n.text) ?? "var(--color-text, #f1f4ef)",
      "--gc-text-muted": (n == null ? void 0 : n.textMuted) ?? "var(--color-text-muted, #b6c0d4)",
      "--gc-border": (n == null ? void 0 : n.border) ?? "var(--color-border, #34516f)"
    }),
    [n]
  ), S = (R) => {
    h(Number(R.target.value));
  };
  return /* @__PURE__ */ pn("div", { className: [Ut.wrapper, r].filter(Boolean).join(" "), style: b, ref: m, children: /* @__PURE__ */ yi(
    "div",
    {
      className: Ut.canvasShell,
      "data-layout": d.layout,
      style: {
        width: d.width ? `${d.width}px` : void 0,
        height: d.height ? `${d.height}px` : void 0
      },
      children: [
        /* @__PURE__ */ pn("div", { className: Ut.canvas, ref: g }),
        /* @__PURE__ */ yi("div", { className: Ut.viewportLabels, "data-layout": d.layout, children: [
          /* @__PURE__ */ pn("div", { className: Ut.splitLabel, children: "Continuous" }),
          /* @__PURE__ */ pn("div", { className: Ut.splitLabel, children: "Discrete" })
        ] }),
        /* @__PURE__ */ pn("div", { className: Ut.controlOverlay, children: /* @__PURE__ */ pn("label", { className: Ut.resolutionCard, children: /* @__PURE__ */ yi("span", { className: Ut.resolutionControl, children: [
          /* @__PURE__ */ pn(
            "input",
            {
              className: Ut.slider,
              type: "range",
              min: "12",
              max: "80",
              step: "1",
              value: c,
              onChange: S
            }
          ),
          /* @__PURE__ */ yi("span", { className: Ut.sliderValue, children: [
            u.toFixed(2),
            "u"
          ] })
        ] }) }) })
      ]
    }
  ) });
}
const Tp = {
  name: "voxel_universe",
  displayName: "Voxel Universe",
  version: "1.0.0",
  paramSchema: {
    gridSize: {
      type: "range",
      label: "Voxel Resolution",
      description: "How many voxels are used per axis. Higher values make each voxel smaller.",
      default: 24,
      min: 12,
      max: 80,
      step: 1
    },
    majorRadius: {
      type: "range",
      label: "Major Radius",
      description: "Overall radius of the torus shape.",
      default: 8,
      min: 4,
      max: 10,
      step: 0.5
    },
    minorRadius: {
      type: "range",
      label: "Minor Radius",
      description: "Thickness of the torus ring.",
      default: 3,
      min: 1,
      max: 5,
      step: 0.25
    }
  },
  defaultParams: {
    gridSize: 24,
    majorRadius: 8,
    minorRadius: 3
  }
};
export {
  yp as default,
  Tp as metadata
};
//# sourceMappingURL=voxel_universe.js.map
